Sometimes the best way to troubleshoot and understand how a Docker Container works, is by exploring the Container. While I believe there are couple of ways to explore, one of the ways I really found useful is docker exec. Basically docker exec let’s you run commands inside a Container, and for a Linux Container we can use docker exec to bash in and run shell commands.
But to bash in of course, you need to have the Container in running state. Here in this post, I have explained how you can setup your own Container, specifically a Linux Container with ASP.NET Core MVC Application running inside.
So let’s proceed.
Currently I have no Containers running.
|docker ps -a|
And I have following set of Images.
Here the dockerwebapp is the Image that I am planning of creating and running a Container from.
I can run the Container by issuing docker run.
In this case, I am going to run docker run –d dockerwebapp as I want the Container to be running in the background, so for next docker commands, I don’t want to open up another PowerShell window.
|docker run -d dockerwebapp|
Now I can see that my container is running, it’s time to explore the image.
You can see that I am now in a Linux shell and I can use shell commands to explore the image. For instance to see the file system.