OS/Linux
Ubuntu 20.04 : Docker 설치
파란크리스마스
2022. 1. 12. 23:38
728x90
출처
필수 패키지 설치
bluesanta@Kubuntu:~$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Docker의 GPG Key 인증
bluesanta@Kubuntu:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
docker repository 등록
CPU, 비트확인
bluesanta@Kubuntu:~$ arch
x86_64
docker repository 등록 (x86_64 인 경우 arch=amd64 사용)
bluesanta@Kubuntu:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
받기:1 https://download.docker.com/linux/ubuntu focal InRelease [57.7 kB]
받기:2 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages [13.5 kB]
기존:3 http://security.ubuntu.com/ubuntu focal-security InRelease
기존:4 http://kr.archive.ubuntu.com/ubuntu focal InRelease
기존:5 http://kr.archive.ubuntu.com/ubuntu focal-updates InRelease
기존:6 http://kr.archive.ubuntu.com/ubuntu focal-backports InRelease
내려받기 71.2 k바이트, 소요시간 1초 (62.6 k바이트/초)
패키지 목록을 읽는 중입니다... 완료
Docker 설치
bluesanta@Kubuntu:~$ sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io
Docker 서비스 등록
bluesanta@Kubuntu:~$ sudo systemctl enable docker && service docker start
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
'docker.service' 서비스 유닛을 시작하려면 인증이 필요합니다.
Authenticating as: bluesanta,,, (bluesanta)
Password:
==== AUTHENTICATION COMPLETE ===
Docker 서비스 상태 확인
bluesanta@Kubuntu:~$ sudo systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-01-13 00:06:34 KST; 4min 39s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 32426 (dockerd)
Tasks: 9
Memory: 29.6M
CGroup: /system.slice/docker.service
└─32426 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
1월 13 00:06:33 Kubuntu dockerd[32426]: time="2022-01-13T00:06:33.657586284+09:00" level=warning msg="Your kernel does not support CPU>
1월 13 00:06:33 Kubuntu dockerd[32426]: time="2022-01-13T00:06:33.657621588+09:00" level=warning msg="Your kernel does not support cgr>
1월 13 00:06:33 Kubuntu dockerd[32426]: time="2022-01-13T00:06:33.657636739+09:00" level=warning msg="Your kernel does not support cgr>
1월 13 00:06:33 Kubuntu dockerd[32426]: time="2022-01-13T00:06:33.657854431+09:00" level=info msg="Loading containers: start."
1월 13 00:06:33 Kubuntu dockerd[32426]: time="2022-01-13T00:06:33.840146057+09:00" level=info msg="Default bridge (docker0) is assigne>
1월 13 00:06:33 Kubuntu dockerd[32426]: time="2022-01-13T00:06:33.933667701+09:00" level=info msg="Loading containers: done."
1월 13 00:06:33 Kubuntu dockerd[32426]: time="2022-01-13T00:06:33.973511657+09:00" level=info msg="Docker daemon" commit=459d0df graph>
1월 13 00:06:33 Kubuntu dockerd[32426]: time="2022-01-13T00:06:33.973742187+09:00" level=info msg="Daemon has completed initialization"
1월 13 00:06:34 Kubuntu systemd[1]: Started Docker Application Container Engine.
1월 13 00:06:34 Kubuntu dockerd[32426]: time="2022-01-13T00:06:34.032735715+09:00" level=info msg="API listen on /run/docker.sock"
portainer 구축하기
portainer docker 생성 옵션
- --name 으로 컨테이너 이름
- -p 호스트 포트 9000 내부포트 9000번
- -d 데몬으로 백그라운드
- --restart always 재부팅시 자동시작
- -v /data~~ 호스트와 컨테이너간 볼륨매칭
- docker.sock도 마찬가지로 공유
- portainer/portainer 이미지
bluesanta@Kubuntu:~$ sudo mkdir -p /data/portainer
bluesanta@Kubuntu:~$ sudo docker run --name portainer -p 9000:9000 -d --restart always -v /data/portainer:/data -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer
0302cf6d04d3e27944441da84eac11a14f6562d144fc7c90070f4bf58dcc3579
portainer 원격 접속