Bootstrap FreeKB - Docker - Mount a file or directory in a container using the docker run -m or --mount command
Docker - Mount a file or directory in a container using the docker run -m or --mount command

Updated:   |  Docker articles

The --mount or --volume option can be used to:

  • mount a file or directory on your Docker system to a file or directory in the container
  • mount an NFS share in the container

You can use:

For example, let's say you have created a PHP container on Docker. You could mount the /usr/local/docker/images directory on the Docker system to /var/www/images as a volume in the PHP container. 

 

As an example, let's say you have a container named foo, and you want to mount an NFS share in the container. In this example, the the docker run command is used to start/create the container using the foo:latest image.

sudo docker run \
--mount \
src=mynfsshare,\
dst=/mnt,\
type=volume,\
volume-driver=local,\
volume-opt=type=nfs,\
volume-opt=device=:/,\
\"volume-opt=o=addr=10.11.12.13,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport\"\
foo:latest

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 8b43c3 in the box below so that we can be sure you are a human.