Bind Mount Without Overwriting Container

I’m creating a docker file for sphinxsearch and having issues with the content of the container being overwritten.

docker run --name some-sphinx -v ~/path/to/host:/usr/local/sphinx mysphinx

Instead of binding the content in the directory in the container to the host, it overwrites the container with an empty directory in place of what existed.

In the mysql docker container, if you mount a directory from the host to /var/lib/mysql it works fine, copying the contents to the host.

I was under the impression that it was a 2-way bind and that it would know to copy from container to host since host was empty and not created.

Maybe i’m not understanding this right, I would appreciate if someone can shed some light on this for me. I am now trying to get RabbitMQ in a docker container and would like to mount the data & config dirs to a local directory on my host machine. I am running into the same issue where it comes up empty and causes the container to have an empty dir in place of what I tried to mount. It works with MySQL, but doesn’t work with sphinx and rabbit, not sure what I am doing wrong or maybe I just don’t understand the -v flag.

I really would appreciate some help on this.

Thanks,

Hatem

Here is what I am trying to run in case it helps:

docker run -d --hostname some-rabbit --name some-rabbit -v ~/Dev/docker/some-rabbit/rabbitmq:/etc/rabbitmq -v ~/Dev/docker/some-rabbit/var:/var/lib/rabbitmq -p 127.0.0.1:61613:61613 -p 127.0.0.1:15672:15672  rabbitmq:3-management

I have the same problem. I am stumped.

This is from a while back and I didn’t get any help on what I was asking. I did come up with a solution for my Dockerfile and exposing what I wanted as far as the directories etc…

What problems are you having exactly, maybe I have the solution with what I ended up working out???