Difficulty: beginner
Estimated Time: 10-15 minutes

In this scenario, you'll learn how to generate an optimized ASP.NET Core based Docker Container using the multi-stage build process. This allows a single Docker Build to use different base images, allowing the SDK to build the binaries but be removed from the final production-ready Docker Image.

The environment is connected to a sandboxed Docker instance, and the code for a default ASP.NET Core application is in the working directory. To view the code use ls and cat <filename>

The machine name Docker is running on is called docker. If you want to access any of the services then use docker instead of localhost or 0.0.0.0.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Optimizing ASP.NET Core Docker Container

Step 1 of 6

Step 1 - Deploy Docker 17.05

The multi-stage build functionality is currently in the version 17.05 of Docker.

Download Developer Build of Docker

Use the command below to download and use the developer build of 17.05.

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected] "curl -L assets.joinscrapbook.com/docker/dockerd-17-05 -o dockerd && mv dockerd /usr/bin/dockerd && chmod +x /usr/bin/dockerd && systemctl restart docker"

Check it successfully upgraded using docker version

You can now use the multi-stage build functionality. Note: This is still in beta and not recommended for production.

Dockerfile