코딩공부/Server

[CI/CD] Django Jenkins 자동 배포하기 - ec2 docker 설치하기 (6)

integerJI 2023. 5. 17. 22:11

 


[CI/CD] Django Jenkins 자동 배포하기 - Django 프로젝트 생성 (1) : https://integer-ji.tistory.com/379
[CI/CD] Django Jenkins 자동 배포하기 - Ec2 Ubuntu 22.04 설치 (2) : https://integer-ji.tistory.com/380
[CI/CD] Django Jenkins 자동 배포하기 - Ec2 모바엑스텀 접속하기 (3) : https://integer-ji.tistory.com/381

[CI/CD] Django Jenkins 자동 배포하기 - Aws Ec2 Django 프로젝트 배포하기 (4) : https://integer-ji.tistory.com/383

[CI/CD] Django Jenkins 자동 배포하기 - ngnix, gunicorn으로 Django 서버 기동하기 (5) : https://integer-ji.tistory.com/385


우분투 서버 준비

나중에 여러가지 사용할 것을 대비하여 docker를 이용해 젠킨스를 설치할겁니다.

 

우선 도커부터 설치!

 

스토리지는 도커에 설치할 이미지들을 대비하여 프리티어의 최고 용량으로 설정(개인적인판단)

 

 

우분투 서버 접속

 

 

ubuntu가 시작되었습니다!

 

명령어를 통해 apt-get 업데이트 

sudo apt-get update

 

 

apt가 https를 통해 패키지를 설치할 수 있도록 설정

sudo apt install apt-transport-https 
sudo apt install ca-certificates 
sudo apt install curl 
sudo apt install software-properties-common

 

이제 도커에서 제공하는 gpg 키를 추가합니다.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg

만약 키를 잘못 등록하거나 우분투 버전에 맞지 않게 옛날 키를 적용하게 된다면 

https://integer-ji.tistory.com/408

 

도커 설치 중 에러

Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy InRelease Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease Hit:4 https://do

integer-ji.tistory.com

해당 에러가 나올 수 있습니다.

 

공식 repository 추가

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

 

마지막으로 apt를 다시 업데이트 해줍니다.

sudo apt-get update

 

 

 

이제 마지막으로

 

도커를 설치해주자 

 

sudo apt install docker-ce

sudo docker run hello-world

hello-world run을 해보면 올바른 명령어를 보내준다. 

 

 

 

하지만 명령어를 도커 명렁어 모두 sudo를 넣어주어야 한다.

 

도커 그룹에 사용자를 넣어주자.

 

 

서버에 도커 그룹이 있는지 확인

sudo groupadd docker

 

 

사용자에게 그룹 추가

sudo usermod -aG docker ubuntu

 

현재 세션에 도커에 대한 그룹 변경 사항 적용!

newgrp docker

 

그러면 sudo 명령어 없이 사용이 가능 합니다!