docker simple tutorial (3) common operations

docker simple tutorial (3) common operations

insert image description here

Before we start, let's understand the difference between images and containers:

  • Mirroring: Just like the configuration files in the song, such as the index.html file we wrote, Dockerfile, etc. A mirror can create multiple containers. For example, if we have a configuration file, we can run multiple containers with docker run based on this configuration file.
  • Container: The container represents the instance we are running, such as the basic website we created in the previous section to run a service. He includes start, stop, delete, pause, etc.

insert image description here

1: View a list of all containers: docker ps -a

docker ps -a

2: View the list of running containers: docker ps

docker ps

3: Run the container: docker run

docker run

If you forget, you can refer to the previous section.

4: Stop the container: docker stop

docker stop <container id>

Use docker psto view all containers and find the corresponding id

For example, a helloworld container we created in the previous section:

Please add a picture description
Then we can execute docker stop 2bbfd11bff2ato shut down the container.

5: Delete the stopped container: docker rm

docker rm <container id>

6: Rename the container: docker rename

docker rename <old_container_id> <new_container_name>

7: Download image: docker pull

docker pull <image name>

like:docker pull nginx

More image files can be downloaded from the docker hub repository

8: View the mirror list: docker images

docker images

9: View image details: docker inspect

docker inspect <image name_or_id>

like:docker inspect helloworld

10: Delete the image: docker rmi

docker rmi <image name_or_id>

11: Build the image: docker build

docker build

If you forget the specific parameters, you can refer to the construction process in the previous section first, which will be introduced in detail later.

Guess you like

Origin blog.csdn.net/qq_41974199/article/details/130303673