Create Docker volume with preexisting data in it

后端 未结 1 1229
后悔当初
后悔当初 2021-01-24 03:47

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 conta

相关标签:
1条回答
  • 2021-01-24 04:29

    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.

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