This rookie encountered such a problem when he just started learning Docker. Let me record it. When starting a container, docker ps shows that there is a problem with the newly started container. Then docker logs <container id> realized that the permissions were insufficient and the directory could not be created. Then I wanted to start it, but the current container was always restarting. I tried docker stop and it returned success. Then docker ps showed that the current container still existed. Then when I tried docker kill, it said that the container was not started. I checked it with docker -help and removed the container with docker rm. However, this command cannot remove a container in the restarting state. You need to docker stop <container id> first and then docker rm it. Of course, the startup failed because of lack of permission. The docker container does not have permission to add the --privileged=true parameter. When running docker-compose, docker-compose up will give priority to using existing containers instead of recreating containers. You need to bring the --force-recreate parameter to recreate the container docker-compose up -d --force-recreate I am a docker novice, so I will record the problems I encountered. Please don't criticize me. Supplement: Docker deletes a large number of stopped containers 1. How to do itThe official recommendation is to use docker rm $(sudo docker ps -a -q) to delete and stop containers in batches. Do not use docker rm -f $(sudo docker ps -a -q), it will delete all containers 2. Why do you do this?1. docker ps -a -qExplanation of the docker ps command: docker ps -a -q lists the numeric IDs of all containers root@haha:~# docker ps --help Usage: docker ps [OPTIONS] List containers Options: -a, --all Show all containers (default shows just running) -f, --filter value Filter output based on conditions provided (default []) --format string Pretty-print containers using a Go template --help Print usage -n, --last int Show n last created containers (includes all states) (default -1) -l, --latest Show the latest created container (includes all states) --no-trunc Don't truncate output -q, --quiet Only display numeric IDs -s, --size Display total file sizes Specifically, docker ps is the command to list containers -a lists all containers -q shows only numeric IDs 2. Explanation of the docker rm command:root@haha:~# docker rm --help Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] Remove one or more containers Options: -f, --force Force the removal of a running container (uses SIGKILL) --help Print usage -l, --link Remove the specified link -v, --volumes Remove the volumes associated with the container -f Force deletion, you can delete the running container -v After the container is started, the data will exist in the form of volumes on the hard disk. Even if the container data is deleted, it will not be deleted. If this parameter is added, the data executed by the container will also be deleted. The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: How to recover data after accidentally deleting ibdata files in mysql5.7.33
>>: Learn how to write neat and standard HTML tags
1. Question: I have been doing insert operations ...
This article shares the specific code of JavaScri...
Browser compatibility is nothing more than style ...
It is difficult to find good image material websi...
Table of contents Introduction to the Decorator P...
Grid layout Attributes added to the parent elemen...
When developing and debugging a web application, ...
Add an input file HTML control to the web page: &...
Table of contents Introduction Instructions Actua...
Table of contents How to view the source code of ...
Preface In this article, we will use Docker to bu...
Table of contents Why choose react-beautiful-dnd ...
CSS display property Note: If !DOCTYPE is specifi...
In this blog, we will discuss ten performance set...