Lesson 3 Docker Container Usage
Lesson 3 Docker Container Usage
1. Help Command
“docker info” is used to display information about the Docker system,
including its configuration and current status. It provides a detailed summary of
Docker images, the number of containers, the Docker daemon, storage drivers,
networks, and other relevant information.
“docker --help” is used to obtain help information for Docker commands.
If it is executed, all available Docker commands and their options will be listed
for reference.
2. Image Command
1) “docker images” lists all images on the local master.
Corresponding Parameters:
REPOSITORY: the repository source of the image.
TAG: the tag of the image.
IMAGE ID: the ID of the image.
CREATED: the creation time of the image.
SIZE: the size of the image.
(The same repository source can have multiple tags representing different
versions of the repository source. You can define different images using
REPOSITORY: TAG. If a tag version for an image is not defined, Docker will
use the “lastest” image by default.)
“docker images” also provides some options:
-a: list all local images
1
-q: display image id only
--digests: display the image’s digest information
2) “docker pull” is used to download images from a selected repository.
Usage:
“docker pull” image repository address/image name: version
Demonstration (it cannot be downloaded, for reference only): “docker pull”
hiwonder/ros-foxy:1.0.0
For example, download the “debian” image: Press “Ctrl+Alt+T” to open the
command line terminal. Then enter “docker pull debian” and press “Enter”.
Enter “docker images” to view the images on the master, and you can see
a “debian” image has been added to the list of images.
2
“DockerHub” repository.
Take researching the “ROS” image for an example. Press “Ctrl+Alt+T” to
open the command line terminal. Then enter “docker search ros” and press
“Enter”.
3. Container Command
The containers can be created only if there are images. Use “debian” to
test. Press “Ctrl+Alt+T” to open the command line terminal. Then enter “docker
pull debian” and press “Enter”.
5
3.3 Exit Container
There are two commands for exiting containers:
1) Enter “exit” directly in the terminal and press “Enter”. This action will
stop the container from running and exit it.
2) Use “crtl+P+Q”. The container exits directly but keeps running. You can
enter the command “docker ps” in the terminal to view the running containers.
3) Enter “exit” in the terminal and press “Enter”. The container stops
running and exits.
4) Enter “docker ps” in the terminal. It displays the running container, and
you can see the earlier exited container is also closed.
2) Enter “docker exec -it efe9 /bin/bash” in the terminal (The container ID
can be shortened as long as it is a unique identifier for the container.) to enter
the running container.
3) Enter “exit” in the terminal and press “Enter”. The container will exit.
7
4) Enter “docker ps” in the terminal. It displays the running container, and
you can see the exited container is not closed.
8
Corresponding Parameters:
UID: User ID.
PID: Process ID.
PPID: Parent Process ID.
C: CPU utilization of the process.
STIME: Start time of the process.
TTY: Terminal associated with the process.
TIME: Total CPU time used by the process.
CMD: Command line used to start the process.
2) Enter “docker inspect efe9” in the terminal to output the JSON data
including detailed information about the container or image.