Reputation: 97
I need to mount a disk using docker-compose.
Currently I can assemble using docker service create
, this way:
docker service create -d \
--name my-service \
-p 8888:80 \
--mount='type=volume,dst=/usr/local/apache2/htdocs,volume-driver=local,volume-opt=type=xfs,volume-opt=device=/dev/sdd' \
httpd
My docker-compose.yml
looks like this:
version: '3.8'
services:
my-service:
image: httpd
ports:
- '80:80'
volumes:
- type: volume
source: my-vol
target: /usr/local/apache2/htdocs
volumes:
my-vol:
driver: local
driver_opts:
type: xfs
o: bind
device: '/dev/sdd'
When uploading the service with docker-compose up
I get the error:
"failed to mount local volume: mount /dev/sdd:/var/lib/docker/volumes/apache_my-vol/_data, flags: 0x1000: not a directory"
How can I configure my docker-compose.yml
to be able to mount a disk?
*Sorry, my bad english..
Upvotes: 0
Views: 1060
Reputation: 158647
The o:
line matches options you'd pass to the ordinary Linux mount(8) command. o: bind
manually creates a bind mount that attaches part of the filesystem somewhere else; this is the mechanic behind Docker's bind-mount system. The important thing that changes here is that it causes the device:
to actually be interpreted as a (host-system) directory to be remounted, and not a device.
Since you're trying to mount a physical device, you don't need the o: bind
option. If you delete that option, the device:
will be interpreted as a device name and you'll be able to mount your disk.
Upvotes: 1