In this post I covered the very basics of getting started with Docker. Once you start to experiment, you’ll need to learn how to debug and inves

Beginner’s Guide to Docker – Part 2 – Debugging a Docker Build

submited by
Style Pass
2021-08-22 15:30:10

In this post I covered the very basics of getting started with Docker. Once you start to experiment, you’ll need to learn how to debug and investigate some of the unexpected things that happen.

In this post, you’ll see references to WebbApplication4 and WebApplication5. This is simply because, during creating the post, I switched, didn’t realise the screenshots were a mix of both, and now don’t consider it worth my time to change. Just consider the two interchangeable.

For this example, we’ll use the default dockerfile that comes with Asp.Net 5; however, we’ll build it up ourselves. Just build a new Asp.Net project.

If we had enabled docker support, we would get a docker file – so let’s build that (this is taken directly from that file). We’ll put it in the same directory as the sln file.

To give a quick rundown of what’s happening in this file: – Where you can see `AS base`, `AS build`, etc, these are known as stages (we’ll come back to that). – The `FROM` statements are telling docker to build on an existing image. – WORKDIR changes the running directory inside the container: if this directory doesn’t exist, then the command will create it. – COPY does what you would think: copies whatever you tell it from the first parameter (the host machine) into the second (the docker container) – RUN executes a command in the container. – Finally, ENTRYPOINT tells docker what to do when it starts the container – it our case, we’re running `dotnet WebApplication4.dll`.

Leave a Comment