WSL Debian 도커 설치

Jmnote (토론 | 기여)님의 2024년 9월 15일 (일) 15:17 판 (→‎자동시작 설정)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

WSL2 Debian 도커 설치
WSL2 데비안 Docker 설치
윈도우 WSL2 Debian 도커 설치

2 설치[ | ]

curl -fsSL https://get.docker.com -o get-docker.sh
sed 's|sleep 20|sleep 1|g' -i get-docker.sh
sudo sh get-docker.sh
testuser@DESKTOP-05A79C1:~$ curl -fsSL https://get.docker.com -o get-docker.sh
testuser@DESKTOP-05A79C1:~$ sudo sh get-docker.sh
# Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be

WSL DETECTED: We recommend using Docker Desktop for Windows.
Please get Docker Desktop from https://www.docker.com/products/docker-desktop


You may press Ctrl+C now to abort this script.
+ sleep 20
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl gnupg >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/debian/gpg" | gpg --dearmor --yes -o /usr/share/keyrings/docker-archive-keyring.gpg
+ sh -c echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian buster stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends  docker-ce-cli docker-scan-plugin docker-ce >/dev/null
+ version_gte 20.10
+ [ -z  ]
+ return 0
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras >/dev/null

================================================================================

To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:

    dockerd-rootless-setuptool.sh install

Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.


To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/

WARNING: Access to the remote API on a privileged Docker daemon is equivalent
         to root access on the host. Refer to the 'Docker daemon attack surface'
         documentation for details: https://docs.docker.com/go/attack-surface/

================================================================================
testuser@DESKTOP-05A79C1:~$ docker -v
Docker version 20.10.8, build 3967b7d
testuser@DESKTOP-05A79C1:~$ docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
testuser@DESKTOP-05A79C1:~$ sudo service docker start
[ ok ] Starting Docker: docker.
testuser@DESKTOP-05A79C1:~$ sudo service docker status
[ ok ] Docker is running.
testuser@DESKTOP-05A79C1:~$ docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
testuser@DESKTOP-05A79C1:~$ docker run hello-world
...
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
For more examples and ideas, visit:
 https://docs.docker.com/get-started/

3 자동시작 설정[ | ]

쉘 접속시 docker가 켜져 있지 않으면 켜도록 .bashrc 에 추가하자.

echo 'pgrep dockerd || sudo service docker start' >> ~/.bashrc
docker 서비스 켜져 있지 않은 경우 (최초 쉘 진입시 포함)
Starting Docker: docker.
testuser@DESKTOP-05A79C1:~$
docker 서비스 켜져 있는 경우
3872
testuser@DESKTOP-05A79C1:~$

4 트러블슈팅 (서비스 시작 안되는 경우)[ | ]

https://github.com/microsoft/WSL/discussions/4872#discussioncomment-99164

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
testuser@DESKTOP-05A79C1:~$ sudo service docker start
[ ok ] Starting Docker: docker.
testuser@DESKTOP-05A79C1:~$ sudo service docker status
[FAIL] Docker is not running ... failed!
testuser@DESKTOP-05A79C1:~$ sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in manual mode
testuser@DESKTOP-05A79C1:~$ sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
update-alternatives: using /usr/sbin/ip6tables-legacy to provide /usr/sbin/ip6tables (ip6tables) in manual mode
testuser@DESKTOP-05A79C1:~$ sudo service docker start
[ ok ] Starting Docker: docker.
testuser@DESKTOP-05A79C1:~$ sudo service docker status
[ ok ] Docker is running.

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}