Welcome to Docker’s .NET Conf challenge!

This lab gets you using .NET Core in Docker containers. You’ll experience compiling code, packaging apps and running containers, using the latest .NET Core 3.0 release.

Difficulty: Beginner (assumes no familiarity with Docker)

Time: Approximately 5 minutes

Tasks:

Task 1: Grab the code

The Play-with-Docker environment is already set up with Docker and Git, so you’re good to go.

Clone the source code from GitHub

Clone the application source into your local session:

Just click the text in these boxes to send the command to your terminal

git clone https://github.com/dockersamples/dotnetconf19.git

Now browse to the source code folder dotnetconf19:

cd dotnetconf19

In there you’ll see a folder called src which contains the .NET code and a file called Dockerfile whch contains the instructions to build and package the app:

ls

Task 2: Build the application image

The Dockerfile has dotnet commands to restore NuGet packages and publish the app:

cat Dockerfile

Even if you’re not familiar with the Dockerfile syntax, you can kind of work out that this is a script to compile the app and package it up to run

You run the script with the docker image build command, which produces a container package called a Docker image:

docker image build --tag dotnetconf:19 .

You’ll see lots of download progress bars, and some familiar output from MSBuild.

The final message Successfully tagged dotnetconf:19 tells you the image has been built and given the tag dotnetconf:19 - which is just the image name.

Task 3: Run a .NET Core container!

A Docker image is a complete packaged app. You can share it on Docker Hub, which is how thousands of open-source and commercial projects now distribute their software.

Your image contains the .NET Core 3.0 runtime, together with the assemblies and configuration for the demo app.

You run the app by running a container from the image:

docker container run dotnetconf:19

Scroll up to read the message from .NET Bot - that’s your .NET Conf code!

If you want to learn more about what’s happened here and how you can use Docker to build cross-platform apps that run on Windows, Linux, Itenal and Arm - check out this blog post:

You’re done!

Enjoy .NET Conf :)

The Play with Docker Training site is always on, and there are plenty more labs you can try at home.