Docker: Container keeps on restarting again on again

后端 未结 11 1572
傲寒
傲寒 2020-12-22 18:55

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 atta

相关标签:
11条回答
  • 2020-12-22 19:05

    try running

    docker stop CONTAINER_ID & docker rm -v CONTAINER_ID

    Thanks

    0 讨论(0)
  • 2020-12-22 19:06

    First check the logs why the container failed. Because your restart policy might bring your container back to running status. Better to fix the issue, Then probably you can build a new image with/without fix. Later execute below command

    docker system prune

    https://forums.docker.com/t/docker-registry-in-restarting-1-status-forever/12717/3

    0 讨论(0)
  • 2020-12-22 19:09

    When docker kill CONTAINER_ID does not work and docker stop -t 1 CONTAINER_ID also does not work, you can try to delete the container:

    docker container rm CONTAINER_ID
    

    I had a similar issue today where containers were in a continuous restart loop.

    The issue in my case was related to me being a poor engineer.

    Anyway, I fixed the issue by deleting the container, fixing my code, and then rebuilding and running the container.

    Hope that this helps anyone stuck with this issue in future

    0 讨论(0)
  • 2020-12-22 19:09

    From personal experience it sounds like there is a problem within your docker container that is not allowing it to restart. So some process within the container is causing the restart to hang or some process is causing the container to crash on start.

    When you start the container make sure you start it detached "-d" if you are going to attach to it. (ex. "docker run -d mediawiki_web_1")

    0 讨论(0)
  • 2020-12-22 19:19

    The docker logs command will show you the output a container is generating when you don't run it interactively. This is likely to include the error message.

    docker logs --tail 50 --follow --timestamps mediawiki_web_1
    

    You can also run a fresh container in the foreground with docker run -ti <your_wiki_image> to see what that does. You may need to map some config from your docker-compose yml to the docker command.

    I would guess that attaching to the media wiki process caused a crash which has corrupted something in your data.

    0 讨论(0)
  • 2020-12-22 19:23

    In my case nginx container was keep on restarting , I checked logs of nginx container and came to know .crt and .key file of a unrequired domain are having errors , so I removed respective .conf file , .crt and .key and then restarted nginx . That's it nginx is working fine without restarting .

    0 讨论(0)
提交回复
热议问题