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

前端 未结 2 870
挽巷
挽巷 2021-01-02 12:25

I want to commit the data in a container\'s shared volume to an image. I cannot seem to do it? I kind of get the impression this perhaps is not possible in Docker but that s

相关标签:
2条回答
  • 2021-01-02 12:46

    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.

    0 讨论(0)
  • 2021-01-02 12:46

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

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

    0 讨论(0)
提交回复
热议问题