Leonardo Bonetti
Leonardo Bonetti

Reputation: 177

Docker-compose volume path dont change after edited

I was running a docker-compose up -d and I received the following error message:

Creating webserver ... 
Creating webserver ... error

ERROR: for webserver  Cannot start service webserver: error while mounting volume '/var/lib/docker/volumes/backend_dhparam/_data': failed to mount local volume: mount /home/root/SemanaOMnistack/backend/dhparam/:/var/lib/docker/volumes/backend_dhparam/_data, flags: 0x1000: no such file or directory

ERROR: for webserver  Cannot start service webserver: error while mounting volume '/var/lib/docker/volumes/backend_dhparam/_data': failed to mount local volume: mount /home/root/SemanaOMnistack/backend/dhparam/:/var/lib/docker/volumes/backend_dhparam/_data, flags: 0x1000: no such file or directory
ERROR: Encountered errors while bringing up the project.

My volume path in docker-compose.yml was:

volumes:
  certbot-etc:
  certbot-var:
  dhparam:
    driver: local
    driver_opts:
      type: none
      device: /home/root/SemanaOMnistack/backend/dhparam/
      o: bind

Thats ok, the path was wrong and I fixed It creating a new user and change the volume in docker-compose.yml:

volumes:
  certbot-etc:
  certbot-var:
  dhparam:
    driver: local
    driver_opts:
      type: none
      device: /home/leo/dev-maps/backend/dhparam/
      o: bind

When I run docker-compose up -d --build the path of volume specified in compose the same error message:

Creating webserver ... 
Creating webserver ... error

ERROR: for webserver  Cannot start service webserver: error while mounting volume '/var/lib/docker/volumes/backend_dhparam/_data': failed to mount local volume: mount /home/root/SemanaOMnistack/backend/dhparam/:/var/lib/docker/volumes/backend_dhparam/_data, flags: 0x1000: no such file or directory

ERROR: for webserver  Cannot start service webserver: error while mounting volume '/var/lib/docker/volumes/backend_dhparam/_data': failed to mount local volume: mount /home/root/SemanaOMnistack/backend/dhparam/:/var/lib/docker/volumes/backend_dhparam/_data, flags: 0x1000: no such file or directory
ERROR: Encountered errors while bringing up the project.

I tried everything like docker system prune -a and clear all cache of my Docker, and the same error message is showing !

I just solve changing the name of volume for example to dhparam2 so... the problem is not the path but the cache.

Anyone knows how to solve it?

Upvotes: 3

Views: 3554

Answers (1)

Nguyen Lam Phuc
Nguyen Lam Phuc

Reputation: 1421

I sometimes have a similar problem with mounting volumes in docker-compose and these are what work for me all the time:

docker-compose down -v --remove-orphans

docker-compose up -d -V --build --force-recreate

Please use --help to understand in more detail what each flag does. Hope this will work for you!

Upvotes: 6

Related Questions