$ /usr/local/bin/docker-compose -f docker-compose.yml up --build --force-recreate
$ /usr/local/bin/docker-compose watch
â Container cloud-solution-cloud-solution-db-1 Started 16.5s
â Container sample-cloud-solution Started 11.8s
WARN[0064] path '/home/user1/path/src/**/*' also declared by a bind mount volume, this path won't be monitored!
Watch configuration for service "cloud-solution-server":
You already mounted src into the container so why do you need syncing the code? It is already âsyncedâ as it is mounted right into the container so when you change it on the host, the exact same files will be visible from the container too. I assume your problem is the warning, but it describes the reason already. Use either bind mounts or syncronize the files by using the watch feature.
It wouldnât make sense to copy the files into the container to a fodler which is on the host. It is like running cp ./README.md ./README.md. You canât copy files to the same location as the source.
Ok, I donât really understand what Iâm doing. My need is to work on code development while it is in the running Docker container. Somehow I must rebuild the container every time I need to see changes Iâve just made. Could you please suggest a possible fix so that it rebuilds automatically when I save the code?
The thing is that it worked fine before when I developed the app in a Docker container using the Flask framework. But this framework is not mature enough, so I started migrating it into FastAPI. It goes slowly because Iâm new to this framework and also because I need to rebuild the container with every change to see how it looks.
I never really used this watch feature, just tested when it came out. I also realized that it doesn1t just synchronize source code but can rerun the build and this is what you are trying, so sorry for not reading your question carfully enough.
But the solution still seems to be clear to me. Remove the bind mount and use the sync action too.
If it worked with bind mount before, it could be a change in compose. If you think it is a bug or it doesnât work with the sync action either, you can report it on GitHub, but I hope the sync action helps.
It works fine for single file app.py but now I also need to include a bunch of html templates, I did it like this: templates/*.html (it did not work for me).
Please advise.