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
Preface The requirement implemented in this artic...
Table of contents Overview Vuex four major object...
Project scenario: When running the Vue project, t...
This article shares the specific code for JavaScr...
Or write down the installation process yourself! ...
Achieve resultsImplementation Code html <base ...
Table of contents Previous 1. What is setup synta...
I used the dialog in closure and drew a dialog wit...
Table of contents The server runs jupyter noteboo...
1. First, download the corresponding database fro...
Without further ado, let's take a look at the...
Related knowledge points Passing values from pa...
Building web pages that comply with Web standards ...
Samba Services: This content is for reference of ...
Log rotation is a very common function on Linux s...