HwangHub

[트러블슈팅] cannot connect to a docker daemon 본문

DEV-STUDY/Infra

[트러블슈팅] cannot connect to a docker daemon

HwangJerry 2023. 10. 26. 21:09
다음 내용은 송곳매 프로젝트 진행 중에 발생한 이슈를 해결한 내용입니다.

 

ubuntu 환경의 ec2에 docker를 이용하여 배포를 하려고 docker를 나름대로 설치하고 docker ps를 수행했는데 다음과 같은 에러가 발생하였다.

 

$ docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
  Is the docker daemon running?

 

알아보니 systemctl status docker 를 통해 체크해보면 대부분 아래와 같이 docker가 ec2 컴퓨터 내에서 실행되고 있지 않아서 그렇다고 한다.

$ systemctl status docker
 docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
   Docs: https://docs.docker.com

 

여기서 많은 한국 블로그들은 systemctl enable docker를 통해 해결했다고 한다.

 

하지만 나는 그렇게 해결되지 않았다.

 

따라서 조금 더 알아보다가 baeldung에서 답을 얻을 수 있었다.

 

명령어는 systemctl start docker 를 입력하면 docker가 정상적으로 실행되었고, 이를 통해 도커를 사용할 수 있게 되었다.

$ systemctl start docker

 

확실히 docker가 동작하는지 확인하기 위해 docker run hello-world를 하니 아래와 같이 response를 얻을 수 있었다.

$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:88ec0acaa3ec199d3b7eaf73588f4518c25f9d34f58ce9a0df68429c5af48e8d
Status: Downloaded newer image for hello-world:latest

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

보다시피 아주 잘 돌아간다.

 

해결해서 기분이 좋다.

 

레퍼런스 : https://www.baeldung.com/ops/docker-cannot-connect

Comments