AWS/AWS 일반

[AWS] EC2 - Docker, Docker-compose 설치하기 (ubuntu 20.04)

yubi5050 2022. 8. 8. 14:56

EC2 만들었다는 가정하에 진행. 해당 글에서는 ubuntu 20.04 로 install 진행

 

1. Docker 설치하기

sudo apt-get update
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -	
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt install -y docker-ce
sudo systemctl status docker => DOCKER RUNNING 확인 가능

 

2. Docker-compose 설치하기

sudo curl \
    -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" \
    -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

 

3. 기타 일반 user에 docker 권한 부여하기 (필요시)

sudo usermod -aG docker ${USER}
sudo service docker restart
logout 
ec2 재접속

 

4. docker_install.sh (위 작업 합친 내용)

# docker install
sudo apt-get -y update
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -	
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt install -y docker-ce

# docker-compose install
sudo curl \
    -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" \
    -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

sudo usermod -aG docker ${USER}
sudo service docker restart