How could one use Docker Compose to synchronize container execution?

How could one use Docker Compose to synchronize container execution?

The problem I’m trying to solve is similar to Docker Compose wait for container X before starting Y. I use Docker Compose to launch several containers, all running on the same host, three of which are PostgreSQL, Liquibase, and a Web application servlet running in Tomcat. The PostgreSQL and Web application containers are both long running while the Liquibase container is ephemeral. The containers must not only start in order, but each container must also wait for the preceding container to be available or complete. In particular, the PostgreSQL server must be ready to process SQL commands before the Liquibase container runs, and the Liquibase schema migration task must complete before the Web application starts to ensure that the database schema is in a valid state.

  • What do 'Masters' and 'Agents ' mean to me in development terms?
  • Access services from docker swarm from public
  • Find container size using python sdk
  • What is the best approach to configure Docker for a webapp?
  • Reuse host binaries or share between containers in Docker
  • running container from private registry with docker swarm
  • I understand that I can achieve this synchronization using two wrapper “wait-for” scripts that poll for certain conditions (and this may be the only available option), the first of which would poll the availability of the PostgreSQL server to process commands while the second, which would run just prior to the Web application, could poll for the presence of a particular database object. However, like process synchronization, I think container synchronization is a common problem that can be addressed with more general inter-process communication and synchronization primitives like semaphores. Docker Compose would likely benefit the most from such synchronization mechanisms, but Docker containers might find them useful, too, for example, to establish multiple synchronization points within a container.

  • docker error when using log-driver=“syslog” on OS X
  • Swagger express gives error inside docker container
  • Control lifetime of .NET Core console application hosted in docker
  • Docker LVM plugin install issues
  • Docker - difference between data volumes and data containers
  • Can Kubernetes be used like Docker Compose?
  • 3 Solutions collect form web for “How could one use Docker Compose to synchronize container execution?”

    Until Docker Compose or Docker supports container synchronization primitives (similar to process synchronization primitives, but accessible from the shell), Dependencies for docker-compose with inotify is one of the better solutions that I’ve found to the Docker Compose container synchronization problem.

    In addition to consul, etcd, and ZooKeeper, MQTT retained messages are another simple mechanism that Docker containers might use to coordinate activities. Mosquito is a lightweight, open-source implementation of MQTT.

    I’ve come to the conclusion that Docker Compose is not the most appropriate tool for container synchronization. Tools like Kubernetes or Marathon facilitate more sophisticated container synchronization. What is the best Docker Linux Container orchestration tool? compares available container synchronization tools.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.