The Docker Desktop application is awesome to work with containers locally via a graphical interface.
You are not required to use it. You can use the CLI commands.
docker ps command lists the currently running containers:
This is the same as running
docker container ls.
In this case, container with name
node-app and ID
739037a911e0 generated from the image
4 minutes ago, is up since 4 minutes, and the port 80 of the host machine is mapped to the container port 3000 using the TCP protocol.
When you know the contained ID, you can stop the container by running
docker container stop <ID>
Once a container is stopped, you can see it using
docker container ls -a:
And you can remove it using
docker container rm:
docker container rm <ID>
You can inspect all the details about a container running
Another useful CLI command is
docker info which gives you lots of information about the current state of your Docker installation, including the number of containers and images.
More docker tutorials:
- Introduction to Docker
- Introduction to Docker Images
- Introduction to Docker Containers
- Installing Docker on macOS
- First steps with Docker after the installation
- Using Docker Desktop to manage a Container
- Create a simple Node.js Hello World Docker Container from scratch
- What to do if a Docker container immediately exits
- Working with Docker Containers from the command line
- Working with Docker Images from the command line
- Sharing Docker Images on Docker Hub
- How to access files outside a Docker container
- How to commit changes to a Docker image
- Updating a deployed container based on a Docker image