Create Docker volume with preexisting data in it

I have a MySQL image that I launch a container from.
I set up dbs , import sql-dump files and create users every time the container is created.

When I work on the container I create various data that are stored in MySQL.

  • docker is not VM , why container need base image OS ? [closed]
  • Why is Dockerized Hadoop datanode registering with the wrong IP address?
  • Error response from bash script calling OCRmyPDF through Docker
  • Websocket (ws4py in Python 3.5) not working in Docker container
  • FOS user bundle doesn't keep logged session
  • How can I reset a Dockerized Rails app for integration testing?
  • I would like to save these extra data in a data volume container [DVC] so I could give the DVC to a colleague and continue from where I stopped.

    The thing is that he will also launch a MySQL container and the initial procedure will be repeated from scratch.

    As I have read, if I mount [--volumes-from] the volumes [/etc/mysql and /var/lib/mysql] from the DVC , the already existing data will be covered and will not be readable.

    Is it possible to use volumes with directories that already have data in them?

  • Docker build hangs during downloads
  • TravisCI - Is it possible to start docker service and expect mysql to work?
  • command line arguments to docker run
  • Why won't my docker-entrypoint.sh execute?
  • docker private image can not be pulled in centos7
  • Docker Data Volumes and Mounting to Host
  • One Solution collect form web for “Create Docker volume with preexisting data in it”

    The short answer is no, but that’s because you’ve gone down the wrong road with your container.

    This is why your image shouldn’t include static data. Keep the static things in the image, and they dynamic things in a data container. (And a startup script to dynamically evaluate anything that needs it)

    You can probably use a docker cp to extract the files into a data container for a one off – or just passthrough mount a local filesystem, to a new mountpoint, and just use tar / rsync with docker exec before re-mounting – but actually I’d suggest rebuild your image to always use a data container for it’s data.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.