Setting up Docker on EC2

After piecing together several different sources, I finally found out how to properly configure docker storage to NOT use a loopback device on EC2. Without going through too much boring details about why this is a good idea to configure a different storage solution, here's the real solution: you need to use the "docker-storage-setup" command, which is installable through yum:


yum install docker docker-storage-setup


You also need a second EBS volume attached to the EC2 instance. You can easily create one through the AWS Console, I attached mine to /dev/sdf.

Next, create the LVM setup:

pvcreate /dev/sdf
lvcreate docker /dev/sdf

Next, setting things up, change /etc/sysconfig/docker-storage-setup:

DEVS="/dev/sdf"
VG="docker"

Next, make sure docker is stopped, and remove /var/lib/docker:

service docker stop
rm -rf /var/lib/docker


Finally, run docker-storage-setup and restart. I actually found I had to restart a few times using "shutdown -r now" just to make sure docker was going to come back up correctly on a fresh start. Theoretically though, you'd just have to do "service docker restart".

0