Recently, I've been trying to get familiar with Docker containers for deployment scenarios, in both Go and .NET Core. One thing I really wanted was an environment that that supported Docker in both Windows and Linux. Fortunately, Windows 10 for Docker now supports this.
In order to use Docker for Windows, you must be running Windows 10 Professional. This is required because Docker for Windows requires Hypervisor, which does not run in Windows 10 Home.
After the Docker for Windows installation, Docker will try to turn Hypervisor on for you, but note that even after upgrading, this might not work. It did not for me. Fortunately, I found a great document for resolving Hypervisor problems here at petri.com in case you have issues (one of the rare times StackOverflow didn't immediately answer my problem!).
So after I installed Docker into my windows 10 by following the steps documented at Docker site (they have done great job documenting, I think), I installed the Visual Studio 2017 RC, which has the latest .NET SDK tooling. I then created a new NET Core Web API using the new project wizard, and checked the option for docker. For reference, that option is circled below:
By selecting this option, the VS docker tooling automatically adds a Dockerfile and a docker-compose component to the project, which can be used to build and run the project in a docker container. This is pretty cool, but one thing I don't like is that using the Visual Studio tooling obfuscates what is actually going on under the covers.
In order to get a better feel for what actually is going on in Docker, I switched to using command line to work with docker, and found a decent tutorial here at stormpath.com. I still had some issues despite following this, and what follows is brief overview of how I got it all working.
First, in my project, I used the following Dockerfile, which I set to "Copy Always" for output option, so the Dockerfile is deployed as part of the "dotnet publish" command.
FROM microsoft/aspnetcore:1.0
COPY . /app
WORKDIR /app
EXPOSE 5000/tcp
ENV ASPNETCORE_ENVIRONMENT Development
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT ["dotnet", "Holidays.dll"]
The first line FROM microsoft/aspnetcore:1.0 pulls in an optimized Linux runtime image for aspnetcore project. The COPY command copies the current directory contents to app folder, and then WORKDIR is set to that /app folder. I found some comments that using anything besides "/app" will not work, but didn't test.
EXPOSE is used to open up specific port from docker to the outside runtime environment.
The next two ENV lines are used to set runtime environment properties. These are not required, but I included them as a form of documentation. If you leave the URL entry out, the container will default to Production environment, and listen on port 80. The URL entry should match the EXPOSE entry. By overriding these I just made it clear where values are coming from.
Finally, the ENTRYPOINT starts up the dotnet process running in Kestrel web server, and launches the dll that you pass as second argument. This should be the name of the dll created during compilation.
After setting up this docker file, then use the following steps at command line, at the root directory of the project you wish build create a container with. I use Git Bash (some people prefer Powershell).
1. dotnet publish
2. docker build bin/debug/netcoreapp1.0/publish -t holidays (note: holidays is what the docker image is named).
3. docker run -d -p 80:5000 --name holidaytest holidays (note: this creates container, and names is based on value after --name argument. In this example holidaytest becomes the name of the container created from the image created in step 2, named holidays. The -p 80:5000 maps the current machines port 80 to the internal port used in the container image set by dockerfile, which was 5000 in my example).
After these steps are complete, you can navigate to the URL for one of the web api controllers on localhost on your machine, and it will run.
To shut down, and then restart this container you can use the following:
docker stop holidaytest
docker start holidaytest
To get a list of images you have on your machine:
docker images
To get a list of containers on your machine, running or not, use:
docker ps -a
It's important to understand the difference between an image, which is just a basic recipe for the container, and the container itself, which is an instantiated version, with port mapping, etc. I didn't quite get this for a while, and caused me some problems!
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from .Net Core Training in Chennai. or learn thru .Net Core Training in Chennai.
ReplyDeleteThe effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Final Year Projects for CSE.
DeleteSoftware management seeks for decision support to identify technologies like JavaScript that meet best the goals and characteristics of a software project or improvement programme. JavaScript Training in Chennai Accessible experiences and repositories that effectively guide that technology selection are still lacking.
Aim of technology domain analysis is to describe the class of context situations (e.g., kinds of JavaScript software projects) in which a software engineering technology JavaScript Training in Chennai can be applied successfully
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
Software can do wonders we are leading software development company in Toronto
ReplyDelete- Amna
Thank you for posting this useful information.
ReplyDeleteBest DOT NET Training in Chennai | DOT NET Course in Chennai
An informative blog and it is very useful
ReplyDeleteDOT NET Course in Chennai
DOT NET Training Institute in Chennai
Such a nice work of software programming.
ReplyDeleteAmna
Owner, SEO Content Writing Service
There a lots of Post I read it but your way of Writing is so good and Informative So Thanks for Sharing and increase our Knowledge
ReplyDeleteAutocad training in Delhi
Autocad training in Noida
Autocad training in Gurgaon
It is surely a very unique post and the admin was putting the large of efforts. I appreciate for this sharing and keep blogging...
ReplyDeleteTableau Training in Chennai
Tableau Course in Chennai
Excel Training in Chennai
Oracle Training in Chennai
Oracle DBA Training in Chennai
Power BI Training in Chennai
Embedded System Course Chennai
Linux Training in Chennai
Tableau Training in Chennai
Tableau Course in Chennai
Since 2007 there https://adesk.cheapsoftwaredownload.net/autodesk_ads.html been a massive shift of people buying goods and services online. But success for an online home business doesn't happen by accident. Here are 3 major factors that always lead to failure.
ReplyDeletegood..
ReplyDeletehow to hack chromebook using crosh
hack tp link wifi username and password
brac ngo written test question
whatsapp ethical hacking
react js developer resume india
integer max value javascript
binatone wifi hack
a certain sum of money amounts to rs.1300 in 2 years and to rs. 1525 in 3.5 years. find the sum and the rate of interest
she spent most of her time tomusic
she most of her time tomusic
Secured homeowner loans are a guarantee for financial aid which comes by providing a guarantee which is your home. Secured homeowner loans are a loan plan which is made to provide to every homeowner and their financial requirements. Also secured homeowner loans are so secured that it is very unlikely that you can go wrong with it. You can choose from a variety of products and pick an interest rate type which is in accordance to your budgeting ways. Secured homeowner loans can be moulded into any shape provided you know what you want. buymodafinilonline.reviews
ReplyDeleteexcellent...!!!
ReplyDeleteSelenium training in chennai
Industrial visit in chennai
Internship
Internships in bangalore for cse students 2019
Free internship in chennai for cse students
Network security projects for cse
Ccna course in chennai
Inplant training in chennai for cse
Inplant training for eee students
Kaashiv infotech chennai
Nice blog!!!
ReplyDeleteInternships in pune for computer science students
Internships in pune for computer science students
Inplant training certificate format
Internships in bangalore for ece students
Industrial training for electronics and communication engineering students
Internship for computer science students in bangalore
Internship for ece students
Mba internship in chennai
Inplant training in chennai for ece
Internship in nagpur for cse
Discovering time to refresh or make your online business postings can some of the time be a test. In any case, once you assert your posting, you can control which data and pictures have appeared on these destinations about your business, which is absolutely justified regardless of the exertion. As a rule, you may as of now have a posting, so it's simply a question of guaranteeing the page for your business. rhinoceros 6 full
ReplyDeleteGood info. Lucky me I reach on your website by accident, I bookmarked it. putlockers
ReplyDeleteGood blog, its really very informative, do more blog under good concepts.
ReplyDeleteDOT NET Training in Bangalore
DOT NET Training in Chennai
DOT NET Training Institutes in Bangalore
DOT NET Course in Bangalore
Best DOT NET Training Institutes in Bangalore
DOT NET Institute in Bangalore
AWS Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
PHP Training in Bangalore
Wonderful Blog!!! Waiting for your upcoming data... thanks for sharing with us.
ReplyDeleteSoftware Testing Training in Chennai
software testing course in chennai
software testing training institute in chennai
software testing course
Software testing training in vadapalani
Software testing training in porur
Python Training in Chennai
Hadoop Training in Chennai
Big data training in chennai
JAVA Training in Chennai
I have to agree with everything in this post. Thanks for useful sharing information.
ReplyDeleteHadoop Training in Chennai
Hadoop Training in Bangalore
Big Data Course in Coimbatore
Big data course in bangalore
Big Data Hadoop Training in Bangalore
Big Data Training in Bangalore
Python Training in Bangalore
salesforce training in bangalore
hadoop training in marathahalli
hadoop training in btm
Get inspired by your blog. Keep doing like this....
ReplyDeleteEthical Hacking Course in Chennai
Ethical hacking course in bangalore
Ethical hacking course in coimbatore
Hacking course in bangalore
Ethical hacking in bangalore
Ethical hacking training in bangalore
Ethical Hacking institute in Bangalore
Ethical hacking Training institute in bangalore
Tally Course in Bangalore
German Classes in Bangalore
This incredible internet web site actually has all of the data I desired concerning this issue and didn’t recognize who to ask.
ReplyDelete
ReplyDeleteHi, you have given really informative post. Thanks for sharing this post to our vision.
Selenium Training in chennai | Selenium Training in anna nagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery
Thank you for the informative post. It was thoroughly helpful to me. Keep posting more such articles and enlighten us.
ReplyDeleteWeb Designing Course Training in Chennai | Web Designing Course Training in annanagar | Web Designing Course Training in omr | Web Designing Course Training in porur | Web Designing Course Training in tambaram | Web Designing Course Training in velachery
Great post, thanks for sharing this amazing blog with us. as we also provide the Best Education Management System Online at affordable prices. for more info visit our website.
ReplyDeleteWeb design Training in Chennai
Web design Training in Velachery
Web design Training in Tambaram
Web design Training in Porur
Web design Training in Omr
Web design Training in Annanagar
I read this blog,Thanks for sharing this information.
ReplyDeletemachine learning classes in Pune
Amazing post.Thanks for sharing.........
ReplyDeleteIELTS Coaching in Hyderabad
IELTS Coaching in Bangalore
IELTS Coaching in Pune
IELTS Coaching in Gurgaon
IELTS Coaching in Delhi
Amazing post..Keep updating your blog
ReplyDeleteDigital Marketing Training in Chennai
Digital Marketing Institute in Chennai
Great post. keep sharing such a worthy information
ReplyDeletecyber security course in bangalore
cyber security training in chennai
Amazing blog...keep sharing
ReplyDeleteIELTS Training in Chennai
IELTS Classes in Chennai
IELTS Coaching in Chennai
IELTS Coaching centre in Chennai
ReplyDeleteWonderful post and more informative!keep sharing Like this!
salesforce institute in bangalore
alesforce institute in bangalore
A unique software-producing intercourse show is called iStripper Torrent. It's an extra hassle-free procedure for laptop computers. Istripper Cracked
ReplyDeleteYou can search for Microsoft Project online and download the application to fix the Microsoft Project 2010 crack that is installed on your PC. Microsoft Office Download With Product Key 2010
ReplyDeleteCompares to having your own sister. A relation and somebody with whom you’ll share your childhood recollections and life experiences. somebody with whom you’ll laugh, weep, and continually trust. Sisters Day Quotes In English
ReplyDeleteGreetings! This page has a lot of useful information on it!
ReplyDeleteClip Studio Paint EX