"docker container run" - Create and Run Container


How to create a new container and run the default command from an image with "docker container run" command?

✍: FYIcenter.com


If you want to create a new container from an image, and start the container with the default command in one step, you can use the "docker container run" command.

1. Get the image name with the "docker image list" command.

$ docker image list | grep hello-world

hello-world  latest  fce289e99eb9  4 months ago        1.84kB

2. Create a new container with random name and start it with its default command.

$ docker container run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:

3. List containers from the "hello-world" image.

$ docker container list --all

CONTAINER ID  IMAGE        COMMAND   CREATED         STATUS                     NAMES
54e2e688aa2f  hello-world  "/hello"  5 seconds ago   Exited (0) 5 seconds ago   awesome_chandrasekhar
2989a342809f  hello-world  "/hello"  10 minutes ago  Created                    my_hello
36f6b8231c20  hello-world  "/hello"  22 minutes ago  Created                    reverent_archimedes
9561c6fa283a  hello-world  "/hello"  40 minutes ago  Exited (0) 29 minutes ago  naughty_chaum


"docker container start --attach" - Attach Console

"docker container create --name" - Name Container

Docker Client (or CLI) on Ubuntu

⇑⇑ Docker Container Platform - Tutorials

2019-03-25, 480👍, 0💬