Docker volume on external hard drive

╄→гoц情女王★ 提交于 2020-07-18 18:22:15

问题


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.


回答1:


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).




回答2:


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


来源:https://stackoverflow.com/questions/40005525/docker-volume-on-external-hard-drive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!