Tools, FAQ, Tutorials:
"docker container run --name" - Run Container with Name
How to create a new container with a given name and run the default command from an image with "docker container run --name" command?
✍: FYIcenter.com
If you want to create a new container with a given name from an image, and start the container with the default command in one step, you can use the "docker container run --name" command.
1. Get the image name with the "docker image list" command.
fyicenter$ docker image list | grep hello-world hello-world latest fce289e99eb9 4 months ago 1.84kB
2. Create a new container with a given name and start it with its default command.
fyicenter$ docker container run --name hello hello-world Hello from Docker! ...
2. Create a new container with another name and start it with its default command.
fyicenter$ docker container run --name hello_again hello-world Hello from Docker! ...
3. List containers from the "hello-world" image.
fyicenter$ docker container list --all CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES e2401260165d hello-world "/hello" 54 seconds ago Exited (0) 46 seconds ago hello_again 2c513219b727 hello-world "/hello" 2 minutes ago Exited (0) 2 minute ago hello ...
As you can see, we are able to create and start a container with each "docker container run --name" command. But if you continue to use the command, more container will be created. So it's probably better to use the "docker container create" and "docker container start" commands to avoid multiple containers.
⇒ "docker container logs" - Fetch Logs
⇐ "docker container run" - Create and Run Container
2021-10-02, 1346🔥, 0💬
Popular Posts:
FYIcenter.com Online Tools: FYIcenter JSON Validator and Formatter FYIcenter JSON to XML Converter F...
How to add request query string Parameters to my Azure API operation 2017 version to make it more us...
What is EPUB 2.0 Metadata "dc:creator" and "dc:contributor" elements? EPUB 2.0 Metadata "dc:creator"...
How to Install Docker Desktop on Windows 10? You can follow this tutorial to Install Docker Desktop ...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...