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…
This comment has been removed by the author.
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.
keven john said…
Setting up Docker on EC2 is a great way to streamline deployment and manage applications efficiently. The step-by-step guide makes it easy even for beginners. On a related note, if you’re working on academic projects like an OBU RAP, consider obu rap report writing help service for expert guidance and professional support to ensure top-quality results!
Nicky Minal said…
Hey everyone, struggling with Docker storage on EC2? I was too! After much digging, I discovered the "docker-storage-setup" command via yum. This avoids the loopback device issue. Think of it like finally unlocking that star player in Retro bowl - achieving peak performance after some serious configuration. It’s a game changer for efficiency. Give it a try!

Kirti Garg said…
The SBI Balanced Advantage Fund offers a great blend of equity and debt, which is perfect for investors looking for a balanced risk approach. The SBI Balanced Advantage Fund Regular Growth plan is an excellent option for long-term wealth creation. Monitoring the SBI Balanced Advantage Fund Regular Plan - Growth NAV gives a clear picture of its performance. If you're considering the Best SIP strategy, this fund is a solid choice for starting a SIP and achieving steady returns