In a recent problem, there is such a phenomenon:The system has a test script that continuously executes the docker run command to run the container. During the test, it was found that sometimes the container was not fully run to the "Up" state, but was in the "created" state, which was very strange. The above environment first checks the container in the "created" state and the dockerd log: (1) The dockerd log only contains "post create" requests, but no "post start" requests are received for the container; (2) Manually executing docker start can pull the container to the "Up" state, indicating that there are no problems with the container and the image itself. Based on the above phenomena, it is suspected that the "docker run" process was not completed and docker run exited. Look at "docker run" immediately. In cli/command/container/run.go, the implementation of the processing function func runRun() of the "docker run" command has the following situation: func runRun(dockerCli *command.DockerCli, flags *pflag.FlagSet, opts *runOptions, copts *runconfigopts.ContainerOptions) error { . . . . . . createResponse, err := createContainer(ctx, dockerCli, config, hostConfig, networkingConfig, hostConfig.ContainerIDFile, opts.name) . . . . . . if err := client.ContainerStart(ctx, createResponse.ID, types.ContainerStartOptions{}); err != nil {) . . . . . } If the "docker run" command exits abnormally after executing the createContainer() function (such as encountering a kill signal), the ContainerStart() function cannot continue to run. This will result in the container being successfully created and in the "created" state, but not actually giving dockerd a "post start", which ultimately causes the above phenomenon. Therefore, it is necessary to monitor the "docker run" command in daily production, such as determining whether it is executed successfully, whether it exits abnormally, whether the return value is 0 when exiting, etc. Supplement: Three ways to run a docker container The first solutionWhen we run docker containers, they are often in the Exited state. For example, the following command docker run -d --name nginx -P nginx /bin/bash will exit after the interactive mode is completed, and re-docker start will not work; If you want the container to be running after running, just remove /bin/bash. The second solutiondocker run -it --name nginxit -P nginx Now the container nginxit is in exit state; As long as we start it with docker, we can use it docker start nginxit The third one is similar to the second one:docker run -it --name nginxit2 -P nginx /bin/bash The foreground and background interactions need to be exited: root@de4dbb27f905:/# exit Then restart: docker start nginxit2 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:
|
<<: MySQL advanced learning index advantages and disadvantages and rules of use
>>: jQuery canvas generates a poster with a QR code
mysql download, install and configure 5.7.20 / 5....
Newer Linux distributions no longer have the rc.l...
You may already know that the length 1 of int(1) ...
No way, no way, it turns out that there are peopl...
Analyze four common methods and principles: float...
Table of contents 1. Preparation 2. Decompression...
There is a table in the project that needs to be ...
Install using the MSI installation package Downlo...
Preface Due to the needs of the company's bus...
Table of contents 1. Script vim environment 2. Ho...
The biggest bottleneck of using zabbix is the d...
Preface When I was studying the front end before,...
mysql accidentally deleted data Using the delete ...
Table of contents Introduction effect principle f...
We better start paying attention, because HTML Po...