Delete the operation method of establishing container in docker
- 2021-07-26 09:10:59
- OfStack
How to delete the container created in docker
1. First list all containers using the docker-s-a command
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f2582758af13 ubuntu "/bin/bash" 2 hours ago Up 2 hours first_ubuntu
6b5b5a969241 centos "/bin/bash" 2 days ago Exited (0) 24 hours ago ubuntu-web
2. Then use the docker stop command to stop the container you want to delete
docker stop <CONTAINER ID|NAME>
3. Now use the following command to delete a single or multiple containers.
docker rm <CONTAINER ID|NAME> <CONTAINER ID|NAME>
Note: You can also use the following command to delete all stopped containers once.
docker rm $(docker ps -a -q)
Content extension:
If your docker-registry is in container, you can't delete image by using the command, you can only delete image file manually. If not, then the docker rmi mirror name can be used for deletion
Docker is a platform for developers and system administrators to develop, migrate, and run applications. After the application program is packaged into Docker Image through Docker, it can be downloaded, started, extended, deleted and migrated in a unified way, which facilitates the deployment and operation and maintenance of the application program.
Docker adopts server/client mode.
Docker clients create, run, or deploy Docker containers by interacting with Docker Daemon. Users can install the Docker client and Docker Daemon on the same system or on different systems. Docker clients communicate via ports or RESTful API and Docker Daemon. Docker is internally composed of three parts: Docker images: Docker image is a read-only template for creating an Docker container. Image can include Linux operating system, Apache or Web application programs, etc. Users can download the created Docker image or create Docker image for other users to use. Each image is composed of many layers, and Docker binds these layers in one image through Union File Systems. Each image is based on a primary image, and then a new layer is added to these primary image through operation instructions, which can be running commands, adding files or directories, creating available operating environments, etc. These operation instructions are saved in the "Dockerfile" file.
Docker registries: Docker registries is used to store Docker image, which is also divided into public and private use. The public Docker registry is Docker Hub, and users can also create private Docker registry and provide other users with Docker images download. Docker containers: Similar to the directory where VMware virtual machine configuration files are stored, it can provide 1-cut elements for application running. Docker Containers can be run, started, stopped, or deleted, and each container is an isolated secure application platform.