How to "undeclare" volumes in docker image?

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/

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

Tags:

Docker

Mysql