Overview

After we learned a little bit a docker and containers, let's use docker for what it was meant to :) I have created a simple HTTP server which listens on port: 1234

Source code you can see in my Git

Packaging application in image, we call dockerize and it is done pretty simle.

Steps

Firstly, you need a Dockerfile in the place of your project. Since my project is on C#.NET Core, I have used the following Dockerfile

Dockerfile

Now, let's go through the steps:

Workdir - The workdir on the container which will be used.

FROM - The external resources which will be used.

COPY & RUN - These are self explanatory I hope.

You have to verify you have docker at least 17.05 or newer. My current one is 19.03:

Build

The building is also done fairy simple.

You can list the images as follows:

Start

Once the image has been built, you can start the container using that image:

Finally, you can check the container: