Step 1: Open the terminal or command prompt and execute the below command.
docker run busybox echo Welcome to Docker programming
$docker run busybox echo Welcome to Docker programming
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
8e674ad76dce: Pull complete
Digest: sha256:7a4d4ed96e15d6a3fe8bfedb88e95b153b93e230a96906910d57fc4a13210160
Status: Downloaded newer image for busybox:latest
Welcome to Docker programming
docker run busybox echo Welcome to Docker programming
We passed 'busybox' image to the docker run command. If the docker has this image in the local registry, it starts a new container instance with this image, else it downloads the image from the public registry.
Once the image is downloaded by docker, it starts the container with 'busybox' image and executes the command "echo Welcome to Docker programming".
Step 2: Execute the command ‘docker ps -a’ to list all the containers in your local system.
$docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d44ecdb5c842 busybox "echo Welcome to Doc…" 3 minutes ago Exited (0) 3 minutes ago wonderful_mendeleev
From the output of 'docker ps -a' command, you can see the container id, image name, command that is executed, name of the image, etc.,
Step 3: Execute the command 'docker run busybox echo Welcome to Docker programming' again.
$docker run busybox echo Welcome to Docker programming
Welcome to Docker programming
Since the image 'busybox' is already presented on the docker local registry, it do not download the image again.
Execute the command 'docker ps -a'.
$docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
35fb6627ce1b busybox "echo Welcome to Doc…" About a minute ago Exited (0) About a minute ago flamboyant_einstein
d44ecdb5c842 busybox "echo Welcome to Doc…" 7 minutes ago Exited (0) 7 minutes ago wonderful_mendeleev
Step 4: Execute the command 'docker images' to list all the images in local registry.
$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest e4db68de4ff2 4 days ago 1.22MB
No comments:
Post a Comment