Docker Volumes Question

I’m new to this so my apologies if this is a newbie question.

When I’m running the following command I was expecting it would bring my local files under the folder into the container but the tmp directory remains empty. What am I missing?

docker run -v /Users/username/Desktop/FolderName/:/tmp IMAGENAME

Thank you :slight_smile:

Docker run -d -it -v /~/Desktop/FolderName/:/tmp IMAGENAME /bin/bash

-d - run detached meaning don’t close…
-i - interactive run in an interactive mode
-t - allocate a sudo-tty
/tmp - as long as this is an empty directory you have permissions for read and write.
try a ~/mydir
/bin/bash for Ubuntu …
/bin/sh for Alpine
I always instal zsh so
/bin/zsh once installed

–name container name - if you want to name your container
I hope this helps

Thanks Don!

Tried with the ~/ option and now I’m seeing this

(VirtualEnvName) SomeRandomComputerName:Desktop username$ Docker run -d -it -v /~/Desktop/Foldername/:/tmp f505e1569aaa /bin/bash
e23c6377c7ecbb0177ee36ba4c3e41018b9ff0ad1bfd93219dc244d90c3b3f08
Docker: Error response from daemon: Mounts denied:
The path /~/Desktop/Foldername/
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences… -> File Sharing.
See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.

I saw different output here with this command:
(VirtualEnvName) SomeRandomComputerName:Desktop username$ docker run -d -it -v /Users/username/Desktop/Foldername/:/tmp f505e1569aaa /bin/bash
f8490f6aa4095039d2339ded1dbe3137622ff770ad424f698e6e2213fab5d030

I just did a touch test.txt to see if I could write in tmp and it created the file - so I don’t think there’s a permissions issue.

Tricky tricky :confused:

Sounds like you need to add the directory to your Docker file shares you can do this by clicking Docker icon in your tool bar and select Preferences, then click the File Share tab and add directories you want to share with Docker.
I have attached an info graphic illustrating this.

Looks like the second time your container loaded.

You can check that with
$ docker ps
you can login to the container with
$ Docker exec -it CONTAINERNAME /bin/bash

Let me know if you need any further help :slight_smile: