Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 575
Leonardo Bonetti Avatar asked Jan 17 '26 23:01

Leonardo Bonetti


1 Answers

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!

like image 165
Nguyen Lam Phuc Avatar answered Jan 20 '26 16:01

Nguyen Lam Phuc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!