Store Docker volume on external hard drive

4.9k Views Asked by At

I am trying to store the data of my container on an 'external hard drive' (/dev/xvdd) that is mounted at /mnt/datadbs.

My docker-compose.yml looks like this:

version: "3":

services:
  ...

volumes:
  prometheus-data:
    driver: local
    driver_opts:
      type: btrfs
      device: /mnt/dataebs

When I start the container, I am getting the following error:

ERROR: for prometheus  Cannot create container for service prometheus: failed to mount local volume: mount /mnt/dataebs:/var/lib/docker/volumes/ubuntu_prometheus-data/_data: block device required

Can someone point me in the right direction? Eventually, I want to be able to store several docker volumes on the 'external hard drive'.

1

There are 1 best solutions below

3
Carlos On

Try changing your named volume declaration type to "bind" instead of "btrfs".

So it would be something like this:

volumes:
  prometheus-data:
    driver: local
    driver_opts:
      type: none
      device: /mnt/dataebs
      o: bind

You can also bind mount directly in your service declaration, so something like this:

app:
    image: appimage
    ports:
      - "8080:8080"
    volumes:
      - /mnt/dataebs:/container/path