Apologies for the 101-nature of this request. I’ve Googled how to add a host directory to a container and the answer is of course docker run -v. However, when I try to run this command
docker run -d -p --name mycontainer -v /mnt/data:/mnt/host myimage/mytag /bin/bash
I receive this message
docker: Error response from daemon: Conflict. The name “/mycontainer” is already in use by container 0335a8d78160361547f90adcda82790be0b284d4bb00ee6aeda6e1705ae99915. You have to remove (or rename) that container to be able to reuse that name…
See ‘docker run --help’.
Basically I have the situation where I have an existing container and I want to access the host mount point /mnt/data inside the docker container. Can someone tell me what I’m doing wrong? Here are my specs:
RHEL 7.2
Docker 1.11.1
docker run --name assigns a unique name to the container that you can use with docker exec, docker rm, and similar commands. You can only have one container at a time with a given name.
If the existing container is stopped, docker rm mycontainer will clean it up; or you can use a different --name, or just leave that option off altogether and Docker will choose an adjective_scientist name for you.
(The docker run command otherwise looks fine to me; you have a stray -p which I’m guessing is a forum copy-and-paste error; but that syntax should in fact make the directory /mnt/data on the host visible as /mnt/host inside the container, so you’ve got that part right.)
Ah. OK. I was thinking that the --name referred to the name of the container to mount the directory in. Thanks. I think that did the trick. Much appreciated.