MOTOSHARE 🚗🏍️

Rent Bikes & Cars Directly from Owners

Motoshare connects vehicle owners with people who need bikes and cars on rent. Owners earn from idle vehicles, and renters get flexible ride options.

Visit Motoshare

docker-compose prepends current directory name to named volumes

docker-compose
Docker

docker-compose

Issues – docker-compose prepends current directory name to named volumes

What actually happens is that the named volume gets prepended with (a simplified version of) the directory name from which the docker-compose command was run.

For instance, if I run from the “dcompos-programs” directory, and I name the volume “my_named_vol”, then I end up with a volume named “dcompos-programs_my_named_vol”.

docker-compose-named-volume.yml:


version: '3'
services:

solr:
 image: alpine:3.5
 container_name: foo
 volumes:
 - my_named_vol:/opt/foo
volumes:
 my_named_vol:

Result:


$ docker-compose -f docker-compose-named-volume.yml up -d && \
> echo "## named volume:" && \
> docker volume ls | grep my_named_vol && \
> echo "## stop" && \
> docker-compose -f docker-compose-named-volume.yml down && \
> echo "## rm volume" && \
> docker volume rm $(docker volume ls | grep my_named_vol | awk '{print $2}')
Creating network "deploymentroot_default" with the default driver
Creating volume "dcompos-programs_my_named_vol" with default driver
Creating foo

Answer
docker-compose uses a project name. By default it’s the directory name which prevents collisions with existing containers. But you can use -p to change the prefix name.

You can use the external volume setting to avoid the prefix.
https://docs.docker.com/compose/compose-file/#external

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x