Docker Community Forums

Share and learn in the Docker community.

Containers with a link don't restart


#1

Hi!

Expected behavior

Containers with the restart: always policy should be started after the engine startup.

Actual behavior

Some containers are, some others aren’t.
Containers that aren’t started all have one thing in common: they possess at least one link to another container.

Information

  • Docker for Windows version 1.12.0 / on Windows 10 Pro
  • Containers all created with compose
  • Example of docker-compose.yml file at the end of this topic: the mariadb container starts while fine the other (which is linked to the mariadb container) don’t start automatically
  • Containers can all be started fine with docker-compose up -d
  • On Debian the containers are restarted as expected upon engine restart
  • I did not stop manually the problematic containers (with docker stop main_pma for instance). If I start them manually with docker start, it works, but when I restart the engine after that, they aren’t restarted (it doesn’t solve the issue).
mariadb:
  container_name: main_mariadb
  image: mariadb
  restart: always
  ports:
    - ...
  volumes:
    - ...
phpmyadmin:
  container_name: main_pma
  build: builds/pma
  restart: always
  ports:
    - ...
  volumes:
    - ...
  links:
    - mariadb:db

Thank you :slight_smile:

Edit: I’d like to add that containers that aren’t started don’t show an existed status time equals to the engine startup time. For instance here, I just restarted my engine (12 sec ago), the main_db has started correctly, but the main_pma hasn’t, and it seems Docker hasn’t even tried to start it since it has exited 10 minutes ago.

$ docker ps -a

838ecc3d0413        docker_phpmyadmin        "/apache.sh"             23 minutes ago      Exited (128) 10 minutes ago                              main_pma
ddca1f400065        mariadb                  "docker-entrypoint.sh"   23 minutes ago      Up 12 seconds                 127.0.0.1:3306->3306/tcp   main_mariadb

Edit: updated to version 1.12.0, I still encounter the same issue


(E2zin) #2

I’m no expert on docker, but I did notice an option in docker-compose’s documentation that might be helping you make this work. Take a look at the depends-on option. Maybe that’s what’s missing.


#3

Hi! Thank you very much for your suggestion. I updated my docker-compose.yml to version 2 and added the depends_on directive (as following) but unfortunately it hasn’t resolved the issue.

version: '2'
services:
  mariadb:
    container_name: main_mariadb
    image: mariadb
    restart: always
    ports:
      - 127.0.0.1:3306:3306
    volumes:
      - mysql:/var/lib/mysql
      - ...

  phpmyadmin:
    container_name: main_pma
    build: builds/pma
    restart: always
    ports:
      - 127.0.0.1:8888:80
    volumes:
      - ...
    depends_on:
      - mariadb
    links:
      - mariadb:db

volumes:
  mysql:
    external: true

(E2zin) #4

Sorry this didn’t work :frowning:

I guess someone else try to answer this one :slight_smile: