How to Specify Docker Volume Location


(chris miller) #1

HI all-

I’m just getting started with Docker-CE running on Ubuntu 18. Have a few containers up and running a things are going well. In my server I have a 500gb ssd, and a 500gb spin drive. Docker is setup on /var/lib/docker, so all my volumes get created there (which is on the SSD). I’m setting up a graylog logging container using the sample yml file, but I would like the volume to be stored on my spin drive which is mounted at /mnt/data. Can someone help point me in the right direction. Here is the snipet from the yml file that I think needs to be modified:

services:
  # MongoDB: https://hub.docker.com/_/mongo/
  mongodb:
    image: mongo:3
    volumes:
      - mongo_data:/data/db
.
.
.
volumes:
  mongo_data:
    driver: local

(Jochen) #2

See https://docs.docker.com/storage/volumes/.

You could also use bind mounts instead of Docker volumes: https://docs.docker.com/storage/bind-mounts/

Anyway, make sure to read https://docs.docker.com/storage/#choose-the-right-type-of-mount for the pros and cons of each storage mechanism.


(system) #3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.