I've got a docker-compose.yml
like this:
db: image: mongo:latest ports: - "27017:27017" server: image: artificial/docker-sails:stable-pm2 command: sails lift volumes: - server/:/server ports: - "1337:1337" links: - db
server/
is relative to the folder of the docker-compose.yml
file. However when I docker exec -it CONTAINERID /bin/bash
and check /server
it is empty.
What am I doing wrong?
The VOLUME command will mount a directory inside your container and store any files created or edited inside that directory on your hosts disk outside the container file structure, bypassing the union file system.
When building an image, you can't mount a volume. However, you can copy data from another image! By combining this, with a multi-stage build, you can pre-compute an expensive operation once, and re-use the resulting state as a starting point for future iterations.
Volumes are stored in a part of the host filesystem which is managed by Docker ( /var/lib/docker/volumes/ on Linux).
Aside from the answers here, it might have to do with drive sharing in Docker Setting. On Windows, I discovered that drive sharing needs to be enabled.
In case it is already enabled and you recently changed your PC's password, you need to disable drive sharing (and click "Apply") and re-enable it again (and click "Apply"). In the process, you will be prompted for your PC's new password. After this process, run your docker command (run or compose) again
Try using:
volumes: - ./server:/server
instead of server/
-- there are some cases where Docker doesn't like the trailing slash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With