Error with volume not mounting docker compose

not sure why but my volume isnt mounting for my docker compose file. keeps saying error file or directory not found... failed to mount local volume: mount /home/md89/Documents/Github/phptest/:/var/lib/docker/volumes/phptest_app/_data, flags: 0x1000: no such file or directory here is the docker compose file
version: "3.9"

services:
caddy:
container_name: caddy
image: caddy:latest
volumes:
- app:/var/www/html
networks:
- phpapp
ports:
- 8080:8080

php:
container_name: php
image: php:8.2-fpm
volumes:
- app:/var/www/html
networks:
- phpapp
ports:
- 9000:9000

volumes:
app:
driver_opts:
type: none
o: bind
device: ./

networks:
phpapp:
name: phpapp
version: "3.9"

services:
caddy:
container_name: caddy
image: caddy:latest
volumes:
- app:/var/www/html
networks:
- phpapp
ports:
- 8080:8080

php:
container_name: php
image: php:8.2-fpm
volumes:
- app:/var/www/html
networks:
- phpapp
ports:
- 9000:9000

volumes:
app:
driver_opts:
type: none
o: bind
device: ./

networks:
phpapp:
name: phpapp
No description
4 Replies
Joao
Joao5mo ago
Do you have any special needs for your mount? If not, it'd be easier to simply do:
volumes:
app:
volumes:
app:
I usually throw in a pair of curly braces just in case, as in the past at least this would cause issues sometimes:
volumes:
app: {}
volumes:
app: {}
It's the same thing since YAML is basically JSON.
ZomaTheMasterOfDisaster
I did change volumes and removed them completely and it did complete the process but caddy didn't work The local host kept saying "connection reset"
Joao
Joao5mo ago
Are you trying to mount your project's folder to /var/www/html? If so, you can use a simple bind mount:
services:
caddy:
image: caddy
volumes:
- ./:/var/www/html
networks:
- phpapp
ports:
- 8080:8080
services:
caddy:
image: caddy
volumes:
- ./:/var/www/html
networks:
- phpapp
ports:
- 8080:8080
You can also omit the image tag if you are using latest since that is the default. Although you shouldn't, always pick a specific version and stick to it until you need to update.
ZomaTheMasterOfDisaster
Yeah that was the change that worked Just php isn't loading on caddy Might try apache next