Why Isn’t Docker Watch Mounting My Files Correctly?

0
15
Asked By CuriousCoder88 On

I'm super frustrated trying to get Docker's watch feature to actually work as expected. I'm using Docker Compose with the `--watch` flag, but it doesn't seem to mount my files and directories before syncing. Here's a snippet of my service configuration:

```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
```

I'm running the command with `docker compose up --watch`. While the `./simple-custom-fork` directory works when mounted directly in `volumes:`, it doesn't work when I try to use the watch actions. The same issue occurs with `./searxng`. Is this a bug or am I missing something in my setup?

3 Answers

Answered By TechieTommy22 On

Have you checked if ditching the `watch` option affects the mounting of your volumes? Also, when you bring your containers down using the `volumes` flag, can you recreate fresh volumes when you spin them back up?

Answered By DockerDude44 On

One thing you could try is removing the `--watch` flag altogether. It might solve your volume mount issue since `docker compose up` by itself will tail the logs by default. If you want to deploy without that log watching, just add `-d` at the end of your command.

Answered By DevelopingDave99 On

I get that you want to watch for changes, but it might be necessary to tweak your approach for the time being. Let me know how you resolve it!

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.