0

I have a stack of containers that are sharing a named volume. The image that contains the files is built to contain code (multiple libraries, thousands of classes).

The issue I am facing is that when I deploy the stack to a docker swarm mode cluster, the containers initialize before the files are fully copied to the volume.

Is there a way to tell that the volume is ready and all files mounted have been copied? I would have assumed that the containers would only get created after the volume is ready, but this does not seem to be the case.

I have an install command that runs in one of the containers sharing that named volume and this fails because the files are not there yet.

version: '3.3'
services:
  php:
    image: code
    volumes:
      - namedvolume:/var/www/html
  web:
    image: nginx
    volumes:
      - namedvolume:/var/www/html
  install:
    image: code
    volumes:
      - namedvolume:/var/www/html
    command: "/bin/bash -c \"somecommand\""
volumes:
  namedvolume:

Or is there something i am doing wrong?

Thanks

Adrian
  • 51
  • 1
  • 5
  • If the data in question is _code_, shouldn’t you build it into the image? That seems like it would avoid this problem? – David Maze Oct 25 '18 at 13:56
  • I am building it into the php image, but am trying to avoid building it to the nginx image as well. Also the install container creates some files which should be shared accross the 2 php containers. – Adrian Oct 25 '18 at 13:58

0 Answers0