Issues with Docker Watch Not Mounting Files Correctly

0
4
Asked By CuriousCoder89 On

I'm struggling to get Docker's watch feature working properly with file mounts. I'm using Docker Compose with the `--watch` flag, but it seems like the volumes aren't being mounted before the service starts. Here's a snippet of my Docker Compose configuration for the `searxng` service:

```yaml
searxng:
container_name: searxng
image: docker.io/searxng/searxng:latest
restart: unless-stopped
networks:
- searxng
ports:
- "127.0.0.1:8080:8080"
volumes:
- ./searxng:/etc/searxng
- ./simple-custom-fork:/usr/local/searxng/searx/static/themes/simple
- searxng-data:/var/cache/searxng:rw
environment:
- SEARXNG_BASE_URL=https://${SEARXNG_HOSTNAME:-localhost}/
- SEARXNG_SECRET=$SEARXNG_SECRET
develop:
watch:
- action: sync+restart
path: ./searxng
target: /etc/searxng
- action: restart
path: ./docker-compose.yaml
```

When I run `docker compose up --watch`, the mounts work fine if I specify the directory in `volumes`, but if I try to use the action to mount it, it fails. This also applies to `./searxng`. Is this a bug, or am I doing something wrong? My Docker version is 29.2.1, and I've included the relevant packages I've installed below:
```
local/docker 1:29.2.1-1
local/docker-buildx 0.31.0-1
local/docker-compose 5.0.2-1
```
I would appreciate any insights into resolving this issue!

1 Answer

Answered By DockerDude23 On

It's worth checking if removing the `watch` flag helps you out with the volume mounting problem. Sometimes, specific flags can interfere with functionality. Also, when you stop the containers using the `volumes` flag, does it let you recreate fresh volumes when you start them up again?

CuriousCoder89 -

Yes, but I still want to use the watch feature to detect changes and rebuild the containers as needed.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.