In Docker, how can I share files between containers and then save them to an image?

你离开我真会死。 提交于 2019-11-30 13:57:20
Bryan

Volumes are outside of container images. That's exactly what they are for - bringing data inside a container that isn't in the image.

From the Docker docs:

A data volume is a specially-designated directory within one or more containers that bypasses the Union File System to provide several useful features for persistent or shared data:

  • Data volumes can be shared and reused between containers
  • Changes to a data volume are made directly
  • Changes to a data volume will not be included when you update an image

If you want to save some changes as part of an image, make the changes inside the image and not in a volume. If you want to share changes across multiple containers, put that data in a volume but you have to make your own arrangements for snapshots, rollback, etc., because Docker doesn't have that feature.

Maybe you would be interested in Flocker.

It looks as though there is an open issue around adding volume layers to docker:

https://github.com/docker/docker/issues/9382

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!