Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy mode does not exist for named volumes in docker-compose file #3969

Closed
toussa opened this issue Sep 22, 2016 · 4 comments
Closed

copy mode does not exist for named volumes in docker-compose file #3969

toussa opened this issue Sep 22, 2016 · 4 comments

Comments

@toussa
Copy link

toussa commented Sep 22, 2016

Hello,

I couldn't find a way to use the "nocopy" flag when using a named volume, as docker do in its "docker run" command :

-v, --volume=[host-src:]container-dest[:]: Bind mount a volume.
The comma-delimited options are [rw|ro], [z|Z],
[[r]shared|[r]slave|[r]private], and [nocopy].
The 'host-src' is an absolute path or a name value.

If neither 'rw' or 'ro' is specified then the volume is mounted in
read-write mode.

The nocopy modes is used to disable automatic copying requested volume
path in the container to the volume storage location.
For named volumes, copy is the default mode. Copy modes are not supported
for bind-mounted volumes.

--volumes-from="": Mount all volumes from the given container(s)

Is there a way to reproduce this behavior in the docker-compose file ?
If not, do you think that could be a feature to add ?

@shin-
Copy link

shin- commented Sep 23, 2016

Hi!

Something like that should work as far as I can tell:

version: "2"
services:
  web:
    image: busybox
    command: top
    volumes:
      - mydata:/data:nocopy
volumes:
  mydata: {}

@toussa
Copy link
Author

toussa commented Sep 27, 2016

Hello shin-, thanks for answering.
You're right, it seems that ":nocopy" flag works !

However it cannot be added in conjunction with ":ro" or "rw"

volumes:
- "wp-files:/usr/share/nginx/html:ro:nocopy"

gives

ERROR: Volume wp-files:/usr/share/nginx/html:ro:nocopy has incorrect format, should be external:internal[:mode]

(the same for :nocopy:ro)

But that could be in another question/github issue I guess

@toussa toussa closed this as completed Sep 27, 2016
@JohnDavidLarsen
Copy link

Options should be comma delimited.
"wp-files:/usr/share/nginx/html:ro,nocopy"

Should work for you.

@supertask
Copy link

supertask commented Jan 10, 2020

"wp-files:/usr/share/nginx/html:ro,nocopy"

Thanks guys! And plus I put the syntax from an official doc to make it sure. ↓

https://docs.docker.com/storage/volumes/

The third field is optional, and is a comma-separated list of options, such as ro. These options are discussed below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants