Docker load files from external HDD to linux machine (centos)

Hi,

I’m new to docker and I’m trying to do the following:

Run a virtual machine via

docker run -ti centos:latest

That will allow me to access an external HDD on my mac machine at location Volumes/Seagate/data.

I’d like to add files to this external HDD but I need to use linux interactively to do so. The external HDD is in ExFAT format.

Is there a way to do this?

I’ve tried

docker run -v $pwd:/home/ -ti centos:latest

while in my current directory, but the machine it launches has an empty home/ folder. Any help would be greatly appreciated! Thank you!

I think its because of the $pwd.

Can you try and change it to {PWD} ( if you're on a linux host, it might be (pwd) instead )

Hi terpz, thanks for the reply. I’m using mac OS to run docker, so it should be $pwd. I changed it to (pwd) and {pwd} and it did not run unfortunately.

I generally prefer to designate the present working directory via pwd, like so, which is a bit more portable across distributions:
docker run -v `pwd`:/home/ -ti centos:latest

If you prefer to use the named environment variables, then on my Mac, using the stock shell, $PWD works, while $pwd is undefined, like so

$ echo $PWD

/Users/myusername

$ echo $pwd

$

which means that

docker run -v $PWD:/home -ti centos:latest

may work for you

1 Like

Hi Bryce,

Thanks for the suggestion! I think you have to use $pwd to access it, as using the other options gave me the following error (Apparently you can’t use uppercase, but lowercase will be recognized):

chrismacbook:bdata chris$ docker run -v $PWD:/home/ -ti centos:latest
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.
chrismacbook:bdata chris$ docker run -v `pwd`:/home/ -ti centos:latest
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.

I was thinking it may have to do with the drive being in ExFat format… But I wouldn’t know what other format to use for big files.

Edit: Thanks Bryce,

I played around with your example a bit and I realized why it wasn’t working – my external harddrive was named with a space (by default) so the pwd and $PWD representations didn’t work. Changing the harddrive name to a single word allowed me to run your commands and it’s working as it should now! I appreciate all the help! Thanks a lot!