How to install Docker and Compose on Amazon Linux 2

Visits: 18373

Here are the instructions to install Docker Compose for Amazon Linux2.

Hi there, I am not going to waste you brains on stupid introductions, If you searched for how to install docker compose on Amazon LInux 2, I won’t add a 2000 word intro to fry your brains!

Amazon Linux 2 is nice and simple and small, but some things need extra attention to install. These commands work for both ARM64 Graviton, etc as well as regular AMD64 amazon linux 2. This also includes installing git and screen. Screen allows you to return to where you left off in disconnected ssh sessions.

Start installing our Cloud Email Server that is based on Docker Compose on Amazon Linux 2, launch the Complete Linux Email Server with Webmail in the AWS Cloud. You can also install ARM64 / Graviton Complete Linux Email Server with Webmail

Leave out this first shebang line if you are just pasting, it should also work as user data

#!/bin/bash
# SSM user didn't start in home dir, so go there
cd
sudo yum update -y
sudo yum install docker containerd git screen -y
sleep 1
wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)
sleep 1
sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/libexec/docker/cli-plugins/docker-compose
sleep 1
chmod +x /usr/libexec/docker/cli-plugins/docker-compose
sleep 5
systemctl enable docker.service --now
sudo usermod -a -G docker ec2-user
sudo usermod -a -G docker ssm-user

Instructions to install Docker Compose on Amazon Linux 2 for both AMD64 and ARM64:

  1. Log in to your Amazon Linux 2 instance.
  2. Open a terminal and run the following command to update your system:
    sudo yum update -y
  3. Install the required packages: Docker, containerd, git, and screen, by running the following command:
    sudo yum install docker containerd git screen -y
  4. Download the latest version of Docker Compose by running the following command:
    wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)
  5. Move the downloaded file to the CLI plugins directory of Docker by running the following command:
    sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/libexec/docker/cli-plugins/docker-compose
  6. Make the Docker Compose file executable by running the following command:
    chmod +x /usr/libexec/docker/cli-plugins/docker-compose
  7. Start and enable the Docker service by running the following command:
    systemctl enable docker.service --now
  8. Add both the ec2-user and ssm-user to the Docker group by running the following commands:
    sudo usermod -a -G docker ec2-user
    sudo usermod -a -G docker ssm-user
  9. Log out and log in again to apply the changes.
  10. To verify the installation, run the following command:
docker-compose version

 

 

 

FROM certbot/certbot:arm64v8-v2.2.0 as base-arm64 FROM certbot/certbot:v2.2.0 as base-amd64

FROM base-${TARGETARCH} RUN apk update && apk add curl RUN mkdir -p /var/log/letsencrypt/ RUN /bin/ln -sf /dev/stderr /var/log/letsencrypt/letsencrypt.log