Why are my volumes not once mounted in a Docker container when using fig?

I see a strange problem in the Docker / Fig environment. My hypothesis is that this is due to a delay in setting volumes into containers, but I'm not sure how to confirm this.

I have a container with the following:

Dockerfile

FROM busybox MAINTAINER Dan Rumney <email> ADD loadsnapshot.sh /loadsnapshot.sh RUN ["chmod", "u+x", "/loadsnapshot.sh"] VOLUME ["/snapshot"] ENTRYPOINT ["/loadsnapshot.sh"] 

loadsnapshot.sh

 #!/bin/sh if [ "$( ls -A /snapshot)" ]; then echo "Loading snapshot..." # Do stuff else echo "No snapshot to load" fi 

In my fig.yml file, I have:

 pdsvol: image: busybox volumes: - "/opt/alfresco/alf_data" - "/data" - "/mysqlbackup" - "/ldapbackup" loader: image: "docker.myregistry.com/snapshot.loader:3.5.0" volumes_from: - pdsvol volumes: - "/opt/snapshots/my-data/:/snapshot/" 

The goal here (which may be obvious) is to start the data container ( pdsvol ) and then fill it with some data that runs on my machine. pdsvol then shared by a bunch of other containers.

I run it to call

 fig up pdsvol 

and then

 fig run --rm loader 

What I expect to see

 builder@beast :/opt/docker-vm$ fig run --rm loader Loading snapshot... ... stuff ... Removing dockervm_loader_run_1... 

and sometimes I do it. However, sometimes I see:

 builder@beast :/opt/docker-vm$ fig run --rm loader No snapshot to load Removing dockervm_loader_run_1... 

I can run fig run --rm loader again and again, and I will get one of two results.

My working theory was that there was some delay in installing the volume, and sometimes this happens before the ENTRYPOINT script is run, and sometimes after. However, if I run:

  docker run --rm -v /opt/snapshots/my-data/:/snapshot/ busybox ls -A /snapshot 

I constantly see the files that I expect ... so this contradicts this theory.

I know that I could hack loadsnapshot.sh and delay the delay and see if this helps, but I would better understand what is happening than fix kludge.

Does anyone have any ideas what is going on here?

BTW: the host system is Linux, so we use our own containers.

Update

I tried putting a 2s delay at the top of loadsnapshot.sh , but that didn't help.

Update 2

I added some logging to fig to reset the configuration that is used to create the container and in each instance (failure or not), the same thing:

 { 'Env': None, 'Hostname': None, 'Entrypoint': None, 'Dns': None, 'Memory': 0, 'OpenStdin': True, 'User': None, 'CpuShares': None, 'AttachStdout': True, 'NetworkDisabled': False, 'WorkingDir': None, 'Cmd': None, 'StdinOnce': True, 'AttachStdin': True, 'Volumes': {u'/snapshot/': {}}, 'MemorySwap': 0, 'VolumesFrom': None, 'Tty': True, 'AttachStderr': True, 'Domainname': None, 'Image': 'docker.myregistry.com/snapshot.loader:3.5.0', 'ExposedPorts': None } 
+6
source share
1 answer

I can reproduce the problem with Docker 1.4.0 / Fig. 1.0.1.

Rollback to Docker 1.3.1 fixed the problem for me.

It is still an open issue affecting many people.

Although # 443 is closed, there are related open issues:

+1
source

Source: https://habr.com/ru/post/974252/


All Articles