How to “decompile” volumes in docker image?

I am writing a Docker file to configure an image for testing a web application. I base it on the image of the tutum / lamp ( https://github.com/tutumcloud/tutum-docker-lamp/blob/master/Dockerfile ) because it seems like a good base to start with.

As part of my docker file, I want to create a mysql database and create something in it. However, the tutum / lamp image declares VOLUME ["/etc/mysql", "/var/lib/mysql" ] , so if I understand correctly, any changes I make to the MySQL database in the Docker file are not will be saved.

  • Do I understand this correctly?

If yes,

  • Is there a way to “decompile” these volumes so that these directories are part of the union file system, like everything else?

Thanks!

+6
source share
2 answers

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

+3
source

It is not possible to modify an existing container, so you have two options:

  • Take the Tutum container and create your own version.
  • Manage container storage using a data container.

Data containers

Create a container that creates a link to the amount of data:

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

This can then be used when starting the mysql database to save data:

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

Data is saved as long as the dbvol container exists. It can be deleted at any stage:

 docker rm dbvol 

Link:

+3
source

Source: https://habr.com/ru/post/976609/


All Articles