0

I'm using docker-compose for deployment, with a 2 docker-compose.yml setup where I'm building the image locally and pulling from docker hub on the server.

Locally:

app:
  build: .
  volumes:
    - "./tmp/volume:/volume"

And on the server:

app:
  image: username/repo:tag
  volumes:
    - "/data/volume:/volume"

Locally my volume mounts to the specified directory fine, with files created by the app persisted there outside the container. On the deployment server, however, this does not happen.

Files are however created and persisted through deploys, even though my deployment script runs docker-compose down -v which presumably removes named & anonymous volumes on the container.

I'm sure I'm doing something wrong, but I can't see what.

numbers1311407
  • 323
  • 2
  • 10

1 Answers1

2

The server here was an EC2 node on AWS, and this turned out to be an issue with mounting an EBS volume after the docker daemon was started.

Essentially docker expected the filesystem before the volume was mounted to /data, and files were actually written to the shadowed /data directory, but invisible because of the mount. This caught me off guard mostly because the mount happened long before deployment when containers were initially created.

So if you mount EBS volumes on an EC2 node, restart the docker service if you expect the containers to be able to access those volumes.

numbers1311407
  • 323
  • 2
  • 10
  • Thanks - this one caught me off guard. Couldn't figure out why nothing was getting mounted from my EBS volume I added after having last started the docker service. – Shogan Apr 30 '17 at 20:15