Using Docker Desktop to manage a Container

By

Learn how to manage a Docker container with Docker Desktop, using its dashboard to start, stop, and restart it, open a CLI, and view logs and stats.

~~~

Docker Desktop gives you a visual dashboard to start, stop, restart, and inspect your containers, without typing any command.

Once you start a Docker container, if you go and click the Docker icon in the toolbar and choose Dashboard, you will see it in Docker Desktop:

Docker Desktop dashboard showing a running docker-tutorial container

The container buttons

Now if you hover the container with the mouse, you will see 5 buttons:

Docker Desktop container with management buttons visible on hover: open in browser, CLI, stop, restart, delete

They are:

You can manage your container lifecycle through them. They mirror the terminal commands: Stop is docker stop, Restart is docker restart, Delete is docker rm.

One thing to know about Delete: it removes the container and everything written inside its filesystem. Any data not stored in a volume is gone. The image stays on your machine, so you can create a fresh container from it any time.

Logs, inspect, and stats

Clicking a container name in the list will reveal more data, including a Logs manager:

Docker Desktop logs tab showing container output with configuration and startup messages

An inspector that tells you useful information about the container, like its environment variables and port mappings:

Docker Desktop inspect tab showing environment variables, nginx version, and port mappings

And stats about the container CPU, Memory, Network and Disk usage:

Docker Desktop stats tab showing CPU usage at 0.00%, memory usage at 5.3 MB, and network/disk usage stats

The logs view is the one I use most. When a container crashes at startup, the logs almost always tell you why.

Trying the lifecycle

Go back and click the Open in browser button and the http://localhost/tutorial URL will open (http://localhost redirects to http://localhost/tutorial in this app):

Browser showing Docker tutorial Getting Started page at localhost/tutorial with command explanations

This is the content of a website that’s provided by our sample image. Now go back to Docker Desktop and press the Stop button

Docker Desktop showing stopped container with grayed out status and management buttons

and refresh the page, it does not work any more:

Browser error page showing site cannot be reached at localhost with ERR_CONNECTION_REFUSED error

The connection is refused because stopping the container also stops the port mapping. Nothing is listening on port 80 any more.

Go back to Docker Desktop and press the Start button, it will work again. A stopped container keeps its filesystem and configuration, so starting it brings everything back as it was.

Try pressing the CLI button. A new terminal window will open and you will automatically be connected to the Docker Container, as the root user:

Terminal window connected to Docker container showing root user prompt after running whoami command

In the above picture the whoami command returns the current user name. This is the same as running docker exec with an interactive shell, handy when you want to look around the container’s filesystem.

Tagged: Docker · All topics
~~~

Related posts about docker: