🙆

Amazon Linux2にdockerとdocker-composeをインストールする手順

2022/06/19に公開

個人的なメモ書きです.

Install docker with yum

sudo yum install docker
sudo systemctl start docker && sudo systemctl enable docker
sudo usermod -a -G docker ec2-user

Install docker-compose

以下で最新版を引っ張ってきます.jqが必要のため注意.

OS_RELEASE="$(uname -s)-$(uname -m)"
LATEST_RELEASE="$(curl https://api.github.com/repos/docker/compose/releases | jq --arg OS_RELEASE $OS_RELEASE -e -r '.[].assets[] | select(.browser_download_url | contains($OS_RELEASE) and (contains("sha256") | not)) | .browser_download_url' | awk -F'/' '{print $8}' | sort -nr | head -n 1)"
sudo curl -L https://github.com/docker/compose/releases/download/"${LATEST_RELEASE}"/docker-compose-"${OS_RELEASE}" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Discussion