If you have a container using volumes persisted between restarts (eg a MySQL container and /var/lib/mysql) if the container fails to restart the volumes get wiped out when the container does start up.
To reproduce this, create a fig.yml containing:
app:
image: ubuntu
ports:
- "6543:6543"
volumes:
- /opt
command: ["/bin/bash", "-c", "/bin/cat </opt/last ; /bin/date > /opt/last"]
When this container runs it attempts to read the date when container was last run and and the write todays date back to the file. I have a mapped port as it's an easy way to stop the container from starting. The first time this is run you see:
$ fig up
Creating bug_app_1...
Attaching to bug_app_1
app_1 | /bin/bash: /opt/last: No such file or directory
bug_app_1 exited with code 0
Gracefully stopping... (press Ctrl+C again to force)
which is expected, if you then run it again you see the date when it was last run (as the /opt volume is persisted:
$ fig up
Recreating bug_app_1...
Attaching to bug_app_1
app_1 | Sat Nov 8 07:20:03 UTC 2014
bug_app_1 exited with code 0
Gracefully stopping... (press Ctrl+C again to force)
If you now start another container with also wants port 6543 and leave it running in another terminal:
docker run -p 6543:6543 --rm -it ubuntu
and attempt to startup the fig managed container again it fails:
$ fig up
Recreating bug_app_1...
Cannot start container fabfd220db3d728213ad6bc410f737ccccbf8414284aad5e27ebdc8cc97f91fe: Bind for 0.0.0.0:6543 failed: port is already allocated
If you now stop the docker container (to release the port) and restart the fig managed container the /opt volume is empty:
$ fig up
Recreating bug_app_1...
Attaching to bug_app_1
app_1 | /bin/bash: /opt/last: No such file or directory
bug_app_1 exited with code 0
Gracefully stopping... (press Ctrl+C again to force)
I would have expected it to still have the /opt volume from the previous runs.
If you have a container using volumes persisted between restarts (eg a MySQL container and /var/lib/mysql) if the container fails to restart the volumes get wiped out when the container does start up.
To reproduce this, create a
fig.ymlcontaining:When this container runs it attempts to read the date when container was last run and and the write todays date back to the file. I have a mapped port as it's an easy way to stop the container from starting. The first time this is run you see:
which is expected, if you then run it again you see the date when it was last run (as the /opt volume is persisted:
If you now start another container with also wants port 6543 and leave it running in another terminal:
and attempt to startup the fig managed container again it fails:
If you now stop the docker container (to release the port) and restart the fig managed container the /opt volume is empty:
I would have expected it to still have the /opt volume from the previous runs.