Share folder between host and container

I’m not very sure if you already found your solution. As far as I understood you started a container without sharing. You already know how to share BUT you have content in that container that you don’t want to be lost.

As charliecurtis says, there’s the “docker cp” command to transfer info to and from the containers from and to the host.

I’d say:

1 - Stop your container.
2 - docker cp your-container:/my/files/in/container/* /my/nice/host/folder
3 - Run another different container from the same image, this time mounting /my/nice/host/folder in /my/files/in/container and there you are: The container will look pretty much the very same, and you’ll have the files from now on inside and outside the container, even the old files created before the change.

Here’s the docker copy syntax: https://docs.docker.com/engine/reference/commandline/cp/

If you feel so, charliecurtis’d advice of running a parallel instance in another port just “to test” is a very good point. If you are so new to docker that you don’t feel launching two parallel instances in different ports, go straight with what I say but do not rm the stopped container. In case of failure you still can kill the new one and re-start the one you stopped.

This will have brief downtimes: The time you “copy” the files while the container is stopped. If you need zero-downtime let us know. I don’t like the idea of copying while the container is started because while running, and after copying the container could have written more files and those would be lost.

If you are happy with a “brief” downtime, stop+copy+re-run-mounted. If you need 100% uptime because you have milions of users, let us know and we’ll try to help.