Docker: set container name inside Dockerfile

Is there a way to set that the container name will be from inside the Docker file? Basically, I want to always have the same name, so I don’t have to run "$ docker ps" after creating and running the image to get its name.

+6
source share
2 answers

Dockerfile is for creating images, not containers.

Now you can specify the names in your containers using the new -name flag for docker run .

If no name is specified, Docker will automatically generate the name

+13
source

Is there a reason why you need to define it in the docker file, and not just indicate your containers at startup?

If you use docker launcher to launch your images, provide a name on the command line:

 --name="" Assign a name to the container 

Docker Run Link

+3
source

All Articles