Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker volume on external hard drive

Tags:

docker

flocker

I'm using a postgres image to run a container locally. I need to process a significant amount of data and I want to use an external hard drive for this. Is it possible to mount a volume on an external hard drive? Can I accomplish what I want with Flocker?

I'm using native docker for mac.

like image 706
Alkis Kalogeris Avatar asked Oct 12 '16 18:10

Alkis Kalogeris


People also ask

Where should I store docker volumes?

Volumes are stored in a part of the host filesystem which is managed by Docker ( /var/lib/docker/volumes/ on Linux). Non-Docker processes should not modify this part of the filesystem. Volumes are the best way to persist data in Docker. Bind mounts may be stored anywhere on the host system.

Can I mount a docker volume?

A Docker volume is a directory somewhere in your Docker storage directory and can be mounted to one or many containers. They are fully managed and do not depend on certain operating system specifics. Before removing the Docker volume, you can open your Docker GUI and inspect the volume by clicking on the data tab.

How do I change docker volume location?

First stop the docker service. Then the volumes can be moved from the default location at /var/lib/docker to the new location. Next the configuration of the docker daemon is edited to point to the new location of the volumes. The next step may not be necessary, but it is a good habit to do it anyway.


2 Answers

Mount the external drive on your mac, and then go to the Docker icon -> preferences -> file sharing. Add your drive path to that list. Then when you do a docker run -v /path/to/drive:/target myimage it will mount your drive into your container (at /target in that example).

like image 199
BMitch Avatar answered Oct 18 '22 12:10

BMitch


In Docker-for-mac, open up the preferences pane. Click on "File Sharing".

You can add the path to your external hard drive there, probably something like /Volumes/Drive.

You'll then be able to use that location as a host volume.

docker run -v /Volumes/Drive/mypostgresdata:/var/lib/postgresql/data \
    --name some-postgres \
    -e POSTGRES_PASSWORD=mysecretpassword \
    -d postgres
like image 30
programmerq Avatar answered Oct 18 '22 12:10

programmerq