Docker - Assign a name to a container using the docker run --name command
by
Jeremy Canfield |
Updated: February 13 2022
| Docker articles
When creating a container using the docker run command, the --name option can be used to give the container a specific name. In this example, a container is created using the foo:latest image, and the name of the container will be foo.
docker run --name foo foo:latest
The docker container ls or docker ps -a command can then be used to display the container. Notice the name of the container is foo.
~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d937372c09ab9 foo:latest "/docker-entrypoin..." 6 minutes ago Created foo
Did you find this article helpful?
If so, consider buying me a coffee over at