compose
compose copied to clipboard
docker-compose v2 incompatible volume handling
Description In docker-compose 1.29 I could mount an empty directory and get the initial content from the overlay FS if the directory was empty (just like with a regular docker -v). This no longer works with docker-compose v2
Steps to reproduce the issue:
- docker-compose up
- ls -lR
Describe the results you received: Empty directories
Describe the results you expected: Directories with the initial content of the overlayfs
Additional information you deem important (e.g. issue happens only occasionally):
config example
version: "3"
services:
app:
image: sample
volumes:
- config:/var/www/html/config
volumes:
config:
driver_opts:
type: none
device: ${PWD}/config
o: bind
I'm not sure why/how this behavior exists with docker-compose v1, but that sounds weird to me an explicit bind mount does not override the image content.
I can understand the benefit for volume to be created with initial content from image. This is the case if your Dockerfile declares a VOLUME and your service configuration does not set an explicit mount for it ("anonymous volumes"), but I didn't know compose v1 allowed to do so with an explicit volume. I guess the main difference is the use of the mount
API in compose v2, while compose v1 uses the legacy bind
API everywhere.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.