named volumes in docker-compose.yml should not be synced
ComaVN opened this issue ยท 5 comments
When defining named volumes in docker-compose.yml, docker-osx-dev assumes them to be relative paths:
myapp:
build: .
volumes:
- /Users/foo/myabsolutepath:/myapp/absolute
- mynamedvolume:/myapp/named
Result:
% docker-osx-dev -s .
2016-01-29 10:15:28 [INFO] Using sync paths from command line args: .
2016-01-29 10:15:28 [INFO] Using sync paths from Docker Compose file at docker-compose.yml: /Users/foo/myabsolutepath mynamedvolume
2016-01-29 10:15:28 [INFO] Complete list of paths to sync: /Users/foo/ /Users/foo/myabsolutepath /Users/foo/mynamedvolume
2016-01-29 10:15:28 [INFO] Using excludes from ignore file .dockerignore: .git vendor
2016-01-29 10:15:28 [INFO] Complete list of paths to exclude: .git vendor
2016-01-29 10:15:28 [INFO] Complete list of paths to include:
2016-01-29 10:15:28 [INFO] Starting docker-osx-dev file syncing
2016-01-29 10:15:28 [INFO] Installing rsync in the Docker Host image
2016-01-29 10:15:29 [INFO] Performing initial sync of paths: /Users/foo /Users/foo/myabsolutepath /Users/foo/mynamedvolume
2016-01-29 10:15:29 [INFO] Initial sync using tar for /Users/foo/myabsolutepath
2016-01-29 10:15:29 [INFO] Initial sync using tar for /Users/foo/mynamedvolume
tar: mynamedvolume: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors.
2016-01-29 10:15:30 [INFO] Initial sync done
2016-01-29 10:15:30 [INFO] Watching: /Users/foo /Users/foo/myabsolutepath /Users/foo/mynamedvolume
I did not expect mynamedvolume
to be synced
I didn't know that was even supported. I thought you used the volumes_from
entry for that? Or is this something new?
Seems like it's been available for a while: docker/compose#1823
Yeah, named volumes are the unofficially/officially (moby/moby#17798) recommended alternative to data-only containers since Docker 1.9.0. We recently switched to them and noticed this as well :)
The named volumes need to be declared in the docker-compose.yml file like this:
version: '2'
volumes:
data:
gems:
services:
rails:
build: .
command: bundle exec rails s
ports:
- "3000:3000"
links:
- redis
volumes:
- gems:/gems
redis:
image: redis
volumes:
- data:/data
Reference: https://docs.docker.com/compose/compose-file/#volumes-volume-driver
One approach would be to parse the names under the top-level volumes:
key and then just not ignore those later when parsing volumes-lines under the service.
Reproduced as well, it really is a problem.
volumes:
ugc: {}
2016-08-23 14:40:58 [INFO] Initial sync using tar for /Users/ain/projects/.../ugc
tar: ugc: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors.