How to “undeclare” volumes in docker image?

后端 未结 3 2058
孤街浪徒
孤街浪徒 2020-12-10 12:54

I am writing a Dockerfile for setting up an image for testing a web application. I am basing it on the tutum/lamp image (https://github.com/tutumcloud/tutum-docker-lamp/blob

相关标签:
3条回答
  • 2020-12-10 13:06

    You can't really undeclare a volume, but you can build your own version of the original image by modifying its dockerfile.

    0 讨论(0)
  • 2020-12-10 13:08

    Not possible to change an existing container, so you have two options:

    1. Take the Tutum container and build your own variant
    2. Manage persistence of the tutum container using a data container.

    Data containers

    Create a container that creates a data volume reference:

    docker run -it --name dbvol -v /var/lib/mysql ubuntu env
    

    This can then be used when running the mysql database to persist the data:

    docker run -d --volumes-from dbvol -p 3306:3306 tutum/mysql:5.6
    

    The data persists as long as the "dbvol" container exists. It can be deleted at any stage:

    docker rm dbvol
    

    Reference:

    • http://blog.tutum.co/2014/05/27/containerize-your-database-volume-with-tutum-mysql-images/
    • https://docs.docker.com/userguide/dockervolumes/
    0 讨论(0)
  • 2020-12-10 13:24

    There has been no change to this problem space in years, so I have created docker-copyedit as a workaround to "undeclare" a volume by editing the metadata of a downloaded image.

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