Yernar Duisebai
Yernar Duisebai

Reputation: 81

how to update docker image without losing its content?

I've been developing a website where I store pictures on the server. I used Docker to run my app. During the testing, I found that when I kill the docker and build an image again I lose all saved pictures. As I understood, when I upload a picture to the server it saves them inside of the container, and when I kill it destroys the created files inside of it. Every time when I add new features I kill the docker and build it again and lose all pictures. What I am doing wrong?

I have committed changes in my container to its image. Can I build the image on top of the existing image? can I merge them?

Upvotes: 2

Views: 7070

Answers (1)

doughellowell
doughellowell

Reputation: 691

You should look into using Docker Volumes

These can be used to persist data between containers

Alternatively you can bind mount storage to a container - but i believe volumes might be more appropriate for you

Upvotes: 3

Related Questions