Showing posts with label Docker. Show all posts
Showing posts with label Docker. Show all posts

Wednesday, November 15, 2017

Building .Net Core Apps for Docker


As mentioned in other posts about Docker, Docker is talk of the town. Docker is a containerization platform which fully lives up to it's motto - "Build, Ship, and Run Any App, Anywhere".

Docker containers provides an additional layer of abstraction on top of virtual machines we're familiar with. Simply put, Docker is a tool that can package an application and it's dependencies in a virtual container that can run on any server (Linux or Windows). This capability gives freedom from underlying operating system constraints and no longer can we say "It works on my machine!". 

New kid on the block ASP.NET Core provides first class Docker support owing it's inherit capability for cross-platform code. 

Visual Studio 2017 supports tooling for adding Docker support for brand new .Net Core Apps or existing .Net Framework apps. You may ask can we run existing Full .Net Framework apps on Docker? We can safely yes if your were to choose Windows containers. 

We must be living in an age of innovation. No time is better than now where we have fairly stable .NET Core 2.0 standard, matured .Net Core stacks (EF Core, ASP.NET Core 2.0) and a feature rich Docker support (did I say about multi-stage deployments).

If you're from .Net school,  you may be looking for a perfect tutorial to dip your toes into Docker world using .Net Core, we can happily recommend perfectly written, very detailed and any .Net programmer can get it. 

Excellent blog post by Maher Jendoubi on ASP.Net Core 2.0 in Docker is an excellent place to begin your Docker journey with .Net Core  stack.




Docker commands cheat sheet


Welcome to world of Docker. Docker is such a blessing for DevOps folks and processes. We still remember days when world is amazed by virtual machines. Oh, I can spin off multiple virtual OSes running on host windows. Virtual machines indeed solved some of the problems. However, they're clunky, heavy in size.

Docker took us to another granular level of containers & images much thinner then virtual OSes, layered images further reducing the size of images and making deployments easy piece of cake. You can further optimize cost savings with Docker containers. Totally isolated, bootstrapped environment which can run on any docker host with any constraints opens up a whole lot of possibilities.

We're impressed with Docker. We integrated Docker containers into our workflows. Docker file is an amazing piece of art. Few concise commands in a text file can initialize, build and run a mission critical app in few seconds.

Let's grasp some useful docker commands. Of course, this list is very small. We'll keep adding as we learn more and more

DOCKER COMMAND
DESCRIPTION
Docker PS
list of running containers
DOCKER RM [ID]
removes container with specific ID
DOCKER Images ls
list of all containers
DOCKER STOP [ID]
stops container
LESS PATH
UNIX command to open a longer file
docker build -t api -f testapp/Dockerfile . &&  docker run -it -p 9000:9000 api
Builds a container using specific docker file and runs containers on a specific port
docker run -it -p 9000:9000 --entrypoint bash api
Runs a shell in a container that is running
CAT  PATH – opens a file in terminal

Q – to exit the file