0

My ssh script on linux

sudo docker pull gitlab.myserver.com:5050/testap/testap-backend
sudo docker stop testap || true && sudo docker rm testap || true
sudo docker run -v testap -dit --restart unless-stopped --network="host" -p 5009:5009 -d --name testap gitlab.myserver.com:5050/testap/testap-backend

My service is uploading some images to wwwroot/ public folder. Each deploy im using above script to restart server. Every time all static files disapears.

Kamil
  • 782
  • 1
  • 9
  • 24
  • 1
    You should not store the images on the local path of docker image... you should map a path from host to docker image and upload image there.. that will help keeping the files on host path when the docker container is destroyed... Or you should use some cloud service to upload the files... – Chetan Sep 03 '21 at 10:19
  • https://stackoverflow.com/questions/59159241/how-to-map-a-docker-containers-directory-to-the-host-with-docker-compose – Chetan Sep 03 '21 at 10:20
  • https://blog.container-solutions.com/understanding-volumes-docker – Chetan Sep 03 '21 at 10:21

1 Answers1

2

This can be achieved with a bind mount.

e.g:

docker container run -v local/path:/path/in/container/wwwroot <add rest of configuration

Morten Toudahl
  • 452
  • 1
  • 4
  • 13
  • Or a volume. Or a data container. Both are better options in hosted environments than storing data on the host. The important part is that the data should be stored outside the container – Panagiotis Kanavos Sep 03 '21 at 10:41