Docker 1일차

타마타마·2022년 10월 23일
0

docker

목록 보기
1/2

docker공부를 시작해보겠당.

설치하기

  1. ubuntu 설치(나는 우분투 설치 후 mobaxterm을 사용했다.)
  2. docker 설치

스크립트 설치

$ sudo wget -qO- https://get.docker.com/ | sh
$ sudo curl -fsSL https://get.docker.com | sh

우분투 패키지로 설치

$ sudo apt update
$ sudo apt install -y \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
    sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
    https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt update
$ sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin

도커 서비스 실행

$ sudo systemctl start docker

부팅했을 때 자동으로 실행하기

$ sudo systemctl start docker

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

해당 오류가 발생할 수 있다.

만약 ubuntu 20.04 버전을 사용하는 경우 발생하는 오류다.

Ubuntu 20.04에서는 system daemon으로 부팅되는 게 아니라서 이 명령어를 못 쓴다.

service사용

나는 systemctl 대신에 service로 확인할 수 있었다.

$ sudo service --status-all

[ - ] apparmor
[ - ] apport
[ - ] atd
...
[-]로 docker가 비활성화 되어 있다.

$ sudo service docker start
* Starting Docker: docker
$ sudo service --status-all
...
 [ - ]  dbus
 [ + ]  docker
 [ ? ]  hwclock.sh

docker부분이 [+]로 채워졌다. 이제 도커를 실행해보면

$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

오류 해결했다.

이미지 확인

$ sudo docker images

REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
ubuntu        latest    216c552ea5ba   2 weeks ago     77.8MB
hello-world   latest    feb5d9fea6a5   13 months ago   13.3kB

0개의 댓글