1

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

Developer
  • 2,113
  • 2
  • 18
  • 26

1 Answers1

2

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
Carlos
  • 1,696
  • 1
  • 14
  • 21
  • Thanks for your answer. I am still getting the same error "block device required" if I change the type to "bind". As far as the second option is concerned, I don't want to use this options because this creates issues with the ownership of the directory (/mnt/dataebs) since the mounted directory is mounted by root. Is there any other option? – Developer Aug 31 '20 at 07:46
  • I would try option 2 just to see if you get the same error. – Carlos Aug 31 '20 at 12:07
  • I updated option 1 after doing some testing, try it and let me know if you still have issues. – Carlos Aug 31 '20 at 12:38