Disable Compose v2 creates a volume whose name is prefixed with your project name

Dear all:

I want to create a volume via Nutanix volume driver by using compose file v2. Below is a part of docker-compose.yml

volumes:
harbordb:
driver: nutanix
harborreg:
driver: nutanix
harborjob:
driver: nutanix

The “deploy_” will be added in front of the volume name I want.But nutanix driver can not recognize the ‘_’ character.

Then the error throw out:
[root@reg Deploy]# docker-compose up -d
Creating volume “deploy_harbordb” with nutanix driver
ERROR: create deploy_harbordb: Error with request: post : volume_groups, got status code 500; err: {u’message’: u"Application error kInvalidArgument raised: ISCSI target name u’deploy_harbordb:nutanix-docker-volume-plugin’ contains an invalid character: u’_’"}

My question is that how can I avoid the prefix for the volume?

Such as I want to create ‘harbordb’ then it will create ‘harbordb’ instead of the default ‘deploy_harbordb’

Thanks for your support.

1 Like

I have the same question. But this does not only happen with volume creation from docker-compose.yml, it also happens with networks.

To illustrate further:

version: '2'
services:
  consul:
    container_name: foobar-consul0
    image: consul
    networks:
      foobar:
        ipv4_address: ${CONSUL_HOST}
    ports:
      - ${CONSUL_PORT}:${CONSUL_PORT}
    volumes:
      - "foobar-consul0:/consul/data"
    command: agent -server -bootstrap -client=0.0.0.0 -http-port=${CONSUL_PORT} -node=foobar
networks:
  foobar:
    ipam:
      config:
        - subnet: 172.25.0.0/16
volumes:
  foobar-consul0:

The top-level network and volume are defined with names foobar-consul0 and foobar, respectively. However, on docker-compose up they will be created with the consul_ prefix added, which was unexpected. Any thoughts on this behavior? Seems like a bug.

This question still ranks high on search engines, but the answer is here: Docker-compose prepends directory name to named volumes