projectatomic / container-storage-setup

Service to set up storage for Docker and other container systems
Apache License 2.0
153 stars 77 forks source link

Docker Storage Setup Not Configuring Docker #279

Closed ricfeatherstone closed 5 years ago

ricfeatherstone commented 6 years ago

Centos7 Host on AWS trying to configure Docker to use an additional EBS volume for storage.

The physical volume and volume group are created but Docker is not configured to use them.

Is my configuration correct and if so any idea what's going wrong and what to do next to resolve?

Thanks

$ cat /etc/sysconfig/docker-storage-setup 
DEVS=/dev/xvdf
VG=docker-vg
STORAGE_DRIVER=overlay2
GROWPART=true
# journalctl -u docker-storage-setup
-- Logs begin at Sat 2018-11-03 14:39:52 GMT, end at Sat 2018-11-03 15:31:25 GMT. --
Nov 03 14:40:00 ip-xxx.eu-west-1.compute.internal systemd[1]: Starting Docker Storage Setup...
Nov 03 14:40:00 ip-xxx.eu-west-1.compute.internal container-storage-setup[1132]: INFO: Volume group backing root filesystem could not be determined
Nov 03 14:40:00 ip-xxx.eu-west-1.compute.internal container-storage-setup[1132]: INFO: Writing zeros to first 4MB of device /dev/xvdf
Nov 03 14:40:00 ip-xxx.eu-west-1.compute.internal container-storage-setup[1132]: 4+0 records in
Nov 03 14:40:00 ip-xxx.eu-west-1.compute.internal container-storage-setup[1132]: 4+0 records out
Nov 03 14:40:00 ip-xxx.eu-west-1.compute.internal container-storage-setup[1132]: 4194304 bytes (4.2 MB) copied, 0.0182566 s, 230 MB/s
Nov 03 14:40:03 ip-xxx.eu-west-1.compute.internal container-storage-setup[1132]: INFO: Device node /dev/xvdf1 exists.
Nov 03 14:40:03 ip-xxx.eu-west-1.compute.internal container-storage-setup[1132]: Physical volume "/dev/xvdf1" successfully created.
Nov 03 14:40:03 ip-xxx.eu-west-1.compute.internal container-storage-setup[1132]: Volume group "docker-vg" successfully created
Nov 03 14:40:03 ip-xxx.eu-west-1.compute.internal systemd[1]: Started Docker Storage Setup.
$ cat /etc/sysconfig/docker-storage
DOCKER_STORAGE_OPTIONS="--storage-driver overlay2 "
$ docker info
...
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
...
# pvdisplay
  --- Physical volume ---
  PV Name               /dev/xvdf1
  VG Name               docker-vg
...
]# vgdisplay 
  --- Volume group ---
  VG Name               docker-vg
...
ricfeatherstone commented 5 years ago

Thinking this could be centos related I've tried on RHEL

# container-storage-setup 
INFO: Volume group backing root filesystem could not be determined
INFO: Writing zeros to first 4MB of device /dev/xvdf
4+0 records in
4+0 records out
4194304 bytes (4.2 MB) copied, 0.0144646 s, 290 MB/s
INFO: Device node /dev/xvdf1 exists.
  Physical volume "/dev/xvdf1" successfully created.
  Volume group "docker-vg" successfully created

Again Docker is not setup to use the disk.

# df /var/lib/docker/
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda2      10473452 2157192   8316260  21% /

What's going on here?

rhatdan commented 5 years ago

@rhvgoyal PTAL

ricfeatherstone commented 5 years ago

I've had some success getting this to work

If I remove STORAGE_DRIVER=overlay2 and delete /etc/sysconfig/docker-storage it runs ok, but this is using device mapper storage.

If I change the configuration as below it runs ok.

$ cat /etc/sysconfig/docker-storage-setup 
STORAGE_DRIVER=overlay2
DEVS=/dev/xvdf
VG=docker-vg
CONTAINER_ROOT_LV_NAME=docker-pool
CONTAINER_ROOT_LV_MOUNT_PATH=/var/lib/docker
# container-storage-setup 
INFO: Volume group backing root filesystem could not be determined
INFO: Writing zeros to first 4MB of device /dev/xvdf
4+0 records in
4+0 records out
4194304 bytes (4.2 MB) copied, 0.0156313 s, 268 MB/s
INFO: Device node /dev/xvdf1 exists.
  Physical volume "/dev/xvdf1" successfully created.
  Volume group "docker-vg" successfully created
  Logical volume "docker-pool" created.
rhvgoyal commented 5 years ago

If you want overlay to use space from /dev/xvdf (and not from root filesystem), then you will have to carve out a logical volume from "docker-vg" volume group, create filesystem on it and mount it on /var/lib/docker and then start docker. container-storage setup can do all this for you if you specify extra options. For example.

CONTAINER_ROOT_LV_NAME="docker-root-lv" CONTAINER_ROOT_LV_SIZE="100%FREE" CONTAINER_ROOT_LV_MOUNT_PATH="/var/lib/docker"

Above will create a logical volume with name "docker-root-lv" from volume group docker-vg and use 100% of free space. Create filesystem on that logical volume and mount it on /var/lib/docker. It will also drop a systemd unit file so that it is mounted on every reboot.

Now if docker is started, it will setup its state in /var/lib/docker, and due to extra mount, all I/O will go to disk /dev/xvdf.