The files are written to the container's writable layer (the container's own private layer on top of the image).
- After
docker stop: the files are still there. A stopped container keeps its writable layer.docker startbrings the container back with the files. - After
docker rm: Docker deletes the writable layer. The files are gone for good. - After deploying a new image version: this creates a new container. It starts with a fresh, empty writable layer. So the old uploads are not there either.
To keep data when you replace containers, mount a named volume at /app/uploads. For a service that scales to many containers, it is better to store uploads in external object storage, such as S3. Treat containers as disposable.
- The data goes into the container's writable layer.
- The data survives docker stop and docker start.
- The data is lost on docker rm.
- A new container from a new image starts with no data.
- Use a volume or external storage to keep the data.
Read more
- Storage overview (https://docs.docker.com/engine/storage/)docs.docker.com
- Volumes (https://docs.docker.com/engine/storage/volumes/)docs.docker.com