Compose: copy mode does not exist for named volumes in docker-compose file

Created on 22 Sep 2016  Â·  4Comments  Â·  Source: docker/compose

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 ?

arevolumes kinquestion

Most helpful comment

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

Should work for you.

All 4 comments

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: {}

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

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

Should work for you.

"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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dazorni picture dazorni  Â·  3Comments

saulshanabrook picture saulshanabrook  Â·  3Comments

HackerWilson picture HackerWilson  Â·  3Comments

davidbarratt picture davidbarratt  Â·  3Comments

Hendrik-H picture Hendrik-H  Â·  3Comments