본문으로 바로가기

Ubuntu Docker 설치하기 및 WSL2 Docker 설치

category 개발지식 2022. 10. 22. 21:19
반응형

1. 우분투 apt 패키지 업데이트

sudo apt-get update

2. Docker respository 추가를 위해 패키지 설치

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

3. Docker GPG Key 추가 

curl -fsSL https://download.docker.com/linux/ubuntu/gpg |
sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

4. Docker repository 추가

 echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

5. apt 패키지 리스트 업데이트 후 Docker 엔진 설치

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

6. Docker 설치 확인하기

docker --version
sudo docker run hello-world

 

참고: https://jkim83.tistory.com/166 [The Programmer:티스토리]

 

 * WSL2 사용 시 Error 발생 

1. Ex) 

Systemctl status docker
System has not been booted with systemd as init system (PID 1). 
Can't operate. Failed to connect to bus: Host is down

 ----- 해결 방법

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig

sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target

exec sudo nsenter -t $(pidof systemd) -m -p su - $LOGNAME

snap version

 

2. Ex) iptable Error

 failed to start daemon: Error initializing network controller: error obtaining controller 
instance: unable to add return rule in DOCKER-ISOLATION-STAGE-1 
chain:  (iptables failed: iptables --wait -A DOCKER-ISOLATION-STAGE-1 -j RETURN: iptables v1.8.7 (nf_tables):  RULE_APPEND failed (No such file or directory): rule in chain DOCKER-ISOLATION-STAGE-1
 (exit status 4))

------ 해결방법

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

sudo dockerd &

 

 

 

반응형

'개발지식' 카테고리의 다른 글

Postman api 문서 만들기  (0) 2023.02.07
AWS 내 node js 설치  (0) 2023.02.07
[Window] 윈도우에 WSL2 설치  (0) 2022.10.22
브라우저 URL 입력했을 때 발생하는 일  (0) 2022.07.13
세마포어와 뮤택스  (0) 2022.07.01