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

Comments

Adam Schule said…
First and foremost, this is a manual procedure that we should avoid. The apps were deployed using Docker, which runs on a single EC2 machine. That's fantastic, but what if you need to deploy a fleet of instances using Docker images? That's where AWS ECS comes in handy. Connecting to other Docker containers will be exceedingly challenging as well. By installing Docker, you can run Docker containers on AWS EC2. You must install Docker CLI, establish an IAM user as an administrator, then set up your AWS account. You can get Docker images from Docker Hub, and you should expose port 80 while running such containers.

You can download now this retro-inspired games for PC for free!
royalbert867 said…
Wow! I'm overjoyed to see your post giving information about Setting up Docker on EC2 because it's quite intriguing. Thanks for sharing this interesting post. Check out the Psychology Assignment Help service for coursework assistance. If you don't believe writing services are worthwhile, they will convince you otherwise! If you offer your explicit instructions to their writer, he will do as you say. You will receive the best paper here, I guarantee it.
julia said…
Once again thanks for this amazing blog you share with us. I must suggest this one with my good friends and family. Keep it up. Now it's time to avail shutters Birmingham for more information.