Docker - Assign a name to a container using the docker run --name command

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 Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 9bf3c in the box below so that we can be sure you are a human.