Is there a way that I can set what the containers name will be from inside the Dockerfile? Basically I want to always have the same name so I won't have to run "$docker ps" after building and running an image to get its name.
The Dockerfile is for creating images not containers. You can now give names to your containers using the new --name flag for docker run . If --name is not provided Docker will automatically generate an alphanumeric string for the container name.
If you are consistent if putting the Dockerfile in a directory with the same name as you want for your image, you can use docker build -t $(basename $PWD) . as your build command. Then you can use CTRL-R search from "build" to find and reuse the command and never have to edit it.
When a container is created using Docker, Docker provides a way to name the container using the the --name <container_name> flag. However, if no name is provided by the user while creating/running a Docker container, Docker automatically assigns the container a name.
The Dockerfile
is for creating images not containers.
You can now give names to your containers using the new --name
flag for docker run
.
If --name
is not provided Docker will automatically generate an alphanumeric string for the container name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With