A
A
ArtiomK2020-07-22 11:08:15
Docker
ArtiomK, 2020-07-22 11:08:15

How to update the contents of the docker volume when updating the project and is it correct to attach folders with code files to the volume?

I have a Flask + Gunicorn app, it's in a docker container. There is Nginx, which is also in a separate container. Requires Nginx to serve static files, including the js file, which are located in the static folder. Accordingly, for this, two containers must have a common volume.

When I just create volume and run containers, there are no problems, all actual js files end up in volume. However, if you update the container image and then restart, the js files remain unchanged.

The problem is not related to Ngnix, as I haven't selected the option to serve static files yet, only normal requests.

I now solve this problem like this:

1. I stop and delete the container that uses volume docker rm -f
2. I delete volumedocker volume rm flask_static_files_volume_name
3. I create volume again

docker volume create  flask_static_files_volume_name

4. I launch the container docker run -v ... appname_container_image

After these actions, the actual js files appear.

I have an opinion that the project code should not fall into the volume and the behavior of docker in this case is correct, since the volumes are also needed so that the files are not lost / changed when the container is restarted.

I didn’t do it initially, but I was asked to figure out why js files are not updated. The setup was most likely done on the basis of this tutorial, where they attach the static folder to volume:
link

Please share your opinion, am I right that folders with project js files should not be volume.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
ArtiomK, 2020-11-15
@ArtiomK

Answer to the question

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question