Docker: Container keeps on restarting again on again

后端 未结 11 1573
傲寒
傲寒 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:24

    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
    
    0 讨论(0)
  • 2020-12-22 19:25

    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.

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

    In my case i removed

    Restart=always

    added

    tty: true
    

    And executed the below command to open shell (daemon process, because docker reads the compose file and stops the container once it reaches the last line of the file).

    docker-compose up -d
    
    0 讨论(0)
  • 2020-12-22 19:27

    Try adding these params to your docker yml file

    restart: "no"
      restart: always
      restart: on-failure
      restart: unless-stopped
      environment:
        POSTGRES_DB: "db_name"
        POSTGRES_HOST_AUTH_METHOD: "trust"
    

    Final file should look something like this

    postgres:
      restart: "no"
      restart: always
      restart: on-failure
      restart: unless-stopped
      image: postgres:latest
      volumes:
        - /data/postgresql:/var/lib/postgresql
      ports:
        - "5432:5432"
      environment:
        POSTGRES_DB: "db_name"
        POSTGRES_HOST_AUTH_METHOD: "trust"
    
    0 讨论(0)
  • 2020-12-22 19:29

    I had forgot Minikube running in background and thats what always restarted them back up

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