Docker: Container keeps on restarting again on aga

2020-02-16 06:26发布

I today deployed an instance of MediaWiki using the appcontainers/mediawiki docker image, and I now have a new problem for which I cannot find any clue. After trying to attach to the mediawiki front container using:

docker attach mediawiki_web_1

which answers Terminated on my configuration for a reason I ignore, trying also:

docker exec -it mediawiki_web_1 bash

I do get something close to an error message:

Error response from daemon: Container 81c07e4a69519c785b12ce4512a8ec76a10231ecfb30522e714b0ae53a0c9c68 is restarting, wait until the container is running

And there is my new problem, because this container never stop restarting. I can see that using docker ps -a which always returns a STATUS of Restarting (127) x seconds ago.

The thing is, I am able to stop the container (I tested) but starting it again seems to bring it back into its restarting loop.

Any idea what could be the issue here ? The whole thing was properly working until I tried to attach to it...

I am sad :-(

标签: docker
8条回答
聊天终结者
2楼-- · 2020-02-16 07:27

tl;dr It is restarting with a status code of 127, meaning there is a missing file/library in your container. Starting a fresh container just might fix it.

Explanation:

As far as my understanding of Docker goes, this is what is happening:

  1. Container tries to start up. In the process, it tries to access a file/library which does not exist.
  2. It exits with a status code of 127, which is explained in this answer.
  3. Normally, this is where the container should have completely exited, but it restarts.
  4. It restarts because the restart policy must have been set to something other than no (the default), (using either the command line flag --restart or the docker-compose.yml key restart) while starting the container.

Solution: Something might have corrupted your container. Starting a fresh container should ideally do the job.

查看更多
乱世女痞
3楼-- · 2020-02-16 07:28

This could also be the case if you have created a systemd service that has:

[Service]
Restart=always
ExecStart=/usr/bin/docker container start -a my_container
ExecStop=/usr/bin/docker container stop -t 2 my_container
查看更多
登录 后发表回答