2. Common commands for docker image containers

 

The operating environment and software and hardware reference configuration are as follows:

2.1. Do not use sudo command

Normally, to operate docker commands, you need to prefix sudo, as follows:

But after adding the docker user group, you don't need to add the sudo prefix. How to add the docker user group (run the command in the host running docker):

After adding the above command, use the [docker images] command to test. If no error is reported, it means that the sudo command is no longer needed. If the following error is reported:

Then execute the following command on the host machine to solve the problem:

 

2.2. Help command

 

2.3. Mirror command

  1. docker pull download image

 

  1. docker images list images

 

  1. docker search search image

 

  1. docker rmi deletes the image

 

2.4. Container command

A container can only be created if you have a mirror. We use the ubuntu mirror to test here. Download the mirror:

 

  1. docker run runs the image to start the container

 

  1. docker ps lists all running containers

 

  1. Exit the container

 

  1. Enter the running container from multiple terminals

 

  1. Start and stop the container

 

  1. Delete the container

 

2.5. Other commonly used commands

  1. View the process information running in the container and support ps command parameters.

 

  1. View the metadata of the container/image

 

 

2.6. Command summary

image-20230424144541215