Docker Community Forums

Share and learn in the Docker community.

Bind Mount Without Overwriting Container

(Hatemjaber) #1

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.

(Hatemjaber) #2

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.



(Hatemjaber) #3

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 -p  rabbitmq:3-management

(Ehartford) #4

I have the same problem. I am stumped.

(Hatemjaber) #5

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???