Docker Image

Learn how to create a docker image using Dockerfile.

It’s time to get your hands dirty again with another chapter project! For this project, you and your team are ready to start testing Docker. You’ve heard about Docker and how awesome containers are but haven’t tried it out yet.

You and your team are in charge of building and deploying an application that is supposed to run on .NET Core. Now’s the perfect time to build some Docker containers for the team to test run the application. Not only will running Docker containers save time in deployments, but developers and QA can have a way to test the application without needing to wait for the infrastructure department to create virtual machines to host the application!

Project overview

In this project, you will:

  • Create a Dockerfile.
  • Create a Linux Docker image running .NET Core hosting a C# web application.
  • Create a Docker container.

By the time you’re done with this project, you will have a fully-functioning web application running on .NET Core within a Docker container!

Building the dockerfile

Now that Docker is installed, it’s time to start getting hands-on experience with it. To start a container running an application, you first need an image. To create an image, you need a Dockerfile. Let’s create one now.

Open up a command prompt or PowerShell console and:

  1. Create a directory to store the Dockerfile again. In this project, this directory will be at \usercode.
  2. Create a new file and save it as Dockerfile in usercode.
  3. Use the docker file provided at the end of this lesson. Each instruction in the Dockerfile is in sequential order that will be executed from the top down. You will see an explanation of each instruction as comments in the example Dockerfile provided.

When run, this Dockerfile:

Get hands-on with 1200+ tech skills courses.