Aug.14.21

iissaacc·2021년 8월 14일
0

TIL

목록 보기
6/10

Prologue

윈도우 환경에서 도커를 쓰려면 필요한 게 많다. 나는 정신적 건강을 챙김과 동시에 서버환경과 비슷한 환경에서 해보려고 우분투(20.04LTS)에서 쓰기로 했다.

Daemon issue

도커 설치는 여기에서 친절히 설명하고 있다. 특정 버전이 필요한 경우가 아니면 복사 붙여넣기만 하면 될 정도로 상세하다. 설치를 마치고 실행해보는데 안 된다. 도커 데몬에 연결할 수 있게 해달란다.

$ sudo docker run hello-world
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

sudo dockerd

가장 간단하게는 sudo dockerd를 입력하면 해결이 되긴 된다. 도커 데몬을 시작하게 하는 명령어인 것 같은데 이렇게 하면 기존 cmd창은 웹서버가 돌아가는 것처럼 먹통이 돼서 cmd창을 하나 더 써야 한다. 로그를 확인해야 할때 쓰면 될 것 같다.

systemctl

systemctl 명령어를 쓰면 데몬이 활성화 되어 있는지 아닌지 확인할 수 있다고 해서 써봤다. 내 경우엔 안 된다.

$ 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

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

service

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

$ sudo service --status-all
 [ - ]  apparmor
 [ - ]  apport
 [ - ]  atd
...

이런 식으로 비활성화 된 건 대괄호 안에 dash로 표시되어 있다. 물음표도 있던데 이건 뭔 뜻인지 모르겠다. 방법을 찾았으니까 활성화해보자.

$ sudo service docker start
* Starting Docker: docker

$ sudo service --status-all
...
 [ - ]  dbus
 [ + ]  docker
 [ ? ]  hwclock.sh
 ...

원래 dash였던 괄호가 +로 채워졌다. 이제 도커를 실행해보면

$ sudo docker run hello-world

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

됐다!

Epilogue

그럴 일을 없겠지만 데몬을 내릴 때는 간단히 startstop으로 바꾸면 된다.

$ sudo service docker stop
* Stopping Docker: docker

$ sudo service --status-all
...
 [ - ]  dbus
 [ - ]  docker
 [ ? ]  hwclock.sh
 ...

Reference

https://stackoverflow.com/questions/44678725/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker

0개의 댓글