본문 바로가기

프로젝트 설정/Docker

[Docker] Docker compose install error (feat. docker-compose와 docker compose)

반응형

회사에서 docker compose를 사용하기 위해서 누군가 apt install docker-compose 를 하였다.

그러자 docker 가 죽고.. 시작하려고 해도 에러가 났다.

1. 처음엔 port가 사용되고 있다는 에러였다.

실행되고 있는 포트를 죽였다.

2. iptables 가 없다고 한다.

iptables 를 install 했다. 하지만 똑같은 에러가 났다.

sudo journalctl -u docker.service


Jan 15 17:24:14 ubuntu systemd[1]: Stopped Docker Application Container Engine.
Jan 15 17:24:14 ubuntu systemd[1]: Starting Docker Application Container Engine...
Jan 15 17:24:14 ubuntu dockerd[11368]: time="2025-01-15T17:24:14.964834049+09:00" level=info msg="Starting up"
Jan 15 17:24:14 ubuntu dockerd[11368]: time="2025-01-15T17:24:14.975388056+09:00" level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved, so using resolv.conf: /run/systemd/resolve/>
Jan 15 17:24:15 ubuntu dockerd[11368]: time="2025-01-15T17:24:15.091849712+09:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
Jan 15 17:24:15 ubuntu dockerd[11368]: time="2025-01-15T17:24:15.112929844+09:00" level=info msg="Loading containers: start."
Jan 15 17:24:15 ubuntu dockerd[11368]: time="2025-01-15T17:24:15.322085751+09:00" level=warning msg="failed to find iptables" error="exec: \"iptables\": executable file not found in $PATH"
Jan 15 17:24:15 ubuntu dockerd[11368]: time="2025-01-15T17:24:15.344765828+09:00" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
Jan 15 17:24:15 ubuntu dockerd[11368]: failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: Iptables not found
Jan 15 17:24:15 ubuntu systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Jan 15 17:24:15 ubuntu systemd[1]: docker.service: Failed with result 'exit-code'.
Jan 15 17:24:15 ubuntu systemd[1]: Failed to start Docker Application Container Engine.
Jan 15 17:24:17 ubuntu systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Jan 15 17:24:17 ubuntu systemd[1]: Stopped Docker Application Container Engine.
Jan 15 17:24:17 ubuntu systemd[1]: docker.service: Start request repeated too quickly.
Jan 15 17:24:17 ubuntu systemd[1]: docker.service: Failed with result 'exit-code'.
Jan 15 17:24:17 ubuntu systemd[1]: Failed to start Docker Application Container Engine.

 

3. docker-ce 야 왜 그러는거야

chatgpt에게 문의하니 docker-ce  패키지가 이상하게 깔린거 같다고 한다.

하지만 docker-ce를 재설치할 경우 현재 컨테이너들의 설정 및 수정하고 있던 코드는 다 날라간다고 보는게 맞다..

Docker가 설치되는 동안 패키지의 설치 후 스크립트에서 오류가 발생한 것으로 보입니다.
특히 test: x: unexpected operator와 같은 메시지는 스크립트에서 test 명령을 사용할 때 문법 오류가 발생한 경우입니다.
Setting up docker-ce (5:24.0.2-1~ubuntu.18.04~bionic) ...
/usr/sbin/invoke-rc.d: 308: test: x: unexpected operator
/usr/sbin/invoke-rc.d: 308: test: x: unexpected operator
/usr/sbin/invoke-rc.d: 317: test: x: unexpected operator
/usr/sbin/invoke-rc.d: 317: test: x: unexpected operator
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "restart" failed.
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Thu 2025-01-16 09:22:34 KST; 43ms ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 237055 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
   Main PID: 237055 (code=exited, status=1/FAILURE)

Jan 16 09:22:34 ubuntu systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Jan 16 09:22:34 ubuntu systemd[1]: docker.service: Failed with result 'exit-code'.
Jan 16 09:22:34 ubuntu systemd[1]: Failed to start Docker Application Container Engine.
dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)

 

4. 혹시 모르니 재부팅해보자

놀랍게도 아무런 달라짐이 없었다.

5. docker와 docker compose 버전 확인하기 (충돌확인하기)

docker 버전은 24.x 였고, docker-compose의 버전은 1.24 인가 였따..

그래서 버전 확인해보라고 했더니 신기한걸 알아냈다.

docker compose가 두개가 있는것이다.

그런데 install 하신분이 mac으로 처리하셨는데 맥에서는 docker compose와 docker-compose가 똑같이 입력되어 이상함을 못 느꼈다고 한다. (linux(ubuntu)에서는 다르다고 뜬다고..)

 

5. 결론 (docker-compose 삭제)

결론은 기존에 있던 docker compose 와 새로 install 된 docker-compose의 충돌이였다.

docker-compose를 삭제하고 나니 잘 되었다.

 

잘됬군 잘됬어

 

버전 확인하는 방법

docker compose version
docker-compose --version

6. 그 다음날 compose restart를 했더니 에러가 났다.

슬프다 재부팅만 했잖아 왜 그러는거

- Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2025-01-16 09:22:42 KST; 33s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 237259 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
   Main PID: 237259 (code=exited, status=1/FAILURE)

Jan 16 09:22:42 ubuntu systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Jan 16 09:22:42 ubuntu systemd[1]: Stopped Docker Application Container Engine.
Jan 16 09:22:42 ubuntu systemd[1]: docker.service: Start request repeated too quickly.
Jan 16 09:22:42 ubuntu systemd[1]: docker.service: Failed with result 'exit-code'.
Jan 16 09:22:42 ubuntu systemd[1]: Failed to start Docker Application Container Engine.


user@ubuntu:~$ journalctl -xe
-- Subject: A start job for unit session-1615.scope has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit session-1615.scope has finished successfully.
--
-- The job identifier is 155180.
Jan 16 09:23:17 ubuntu systemd[1]: Configuration file /run/systemd/system/netplan-ovs-cleanup.service is marked world-inaccessible. This has no effect as configuration data is accessible via APIs with>
Jan 16 09:23:18 ubuntu sshd[238061]: error: bind [::]:10082: Address already in use
Jan 16 09:23:18 ubuntu sshd[238061]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 10082
Jan 16 09:23:18 ubuntu systemd[1]: Starting Docker Application Container Engine...
-- Subject: A start job for unit docker.service has begun execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit docker.service has begun execution.
--
-- The job identifier is 155269.
Jan 16 09:23:18 ubuntu sshd[237927]: pam_unix(sshd:session): session closed for user 
Jan 16 09:23:18 ubuntu systemd[1]: session-1615.scope: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit session-1615.scope has successfully entered the 'dead' state.
Jan 16 09:23:18 ubuntu systemd-logind[1057]: Session 1615 logged out. Waiting for processes to exit.
Jan 16 09:23:18 ubuntu systemd-logind[1057]: Removed session 1615.
-- Subject: Session 1615 has been terminated
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- Documentation: https://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A session with the ID 1615 has been terminated.
Jan 16 09:23:18 ubuntu dockerd[238066]: time="2025-01-16T09:23:18.270859431+09:00" level=info msg="Starting up"
Jan 16 09:23:18 ubuntu dockerd[238066]: failed to load listeners: no sockets found via socket activation: make sure the service was started by systemd
Jan 16 09:23:18 ubuntu systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit docker.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Jan 16 09:23:18 ubuntu systemd[1]: docker.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit docker.service has entered the 'failed' state with result 'exit-code'.
Jan 16 09:23:18 ubuntu systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: A start job for unit docker.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit docker.service has finished with a failure.
--
-- The job identifier is 155269 and the job result is failed.

docker.socket 상태 확인

현재 docker.socket 서비스가 "service-start-limit-hit" 상태로 실패한 것으로 보입니다.
이 오류는 docker.socket이 너무 자주 재시작을 시도하면서 발생합니다. 일반적으로 systemd는 서비스가 연속적으로 실패하면 더 이상 재시작하지 않도록 제한을 두기 때문입니다.
 sudo systemctl status docker.socket
● docker.socket - Docker Socket for the API
     Loaded: loaded (/lib/systemd/system/docker.socket; enabled; vendor preset: enabled)
     Active: failed (Result: service-start-limit-hit) since Thu 2025-01-16 09:23:25 KST; 59s ago
   Triggers: ● docker.service
     Listen: /run/docker.sock (Stream)

Jan 16 09:23:20 ubuntu systemd[1]: Starting Docker Socket for the API.
Jan 16 09:23:20 ubuntu systemd[1]: Listening on Docker Socket for the API.
Jan 16 09:23:25 ubuntu systemd[1]: docker.socket: Failed with result 'service-start-limit-hit'.

docker.socket 설정 변경하기

case1

안되면 case 2 실행

sudo systemctl edit docker.socket
[Service]
RestartSec=5s
StartLimitIntervalSec=0
# 저장 후 아래 명령어 실행
sudo systemctl daemon-reload
sudo systemctl restart docker.socket
sudo systemctl status docker.service
# 안되면 시스템 리붓
sudo reboot

case2

sudo systemctl edit docker.socket Cannot edit units if not on a tty. 와 같이 원격지에서 접속하여 systemctl edit을 사용할 수 없는 경우

sudo nano /etc/systemd/system/docker.socket
# 또는
sudo nano /lib/systemd/system/docker.socket
# 또는 (오버라이드용)
sudo mkdir -p /etc/systemd/system/docker.socket.d
sudo nano /etc/systemd/system/docker.socket.d/override.conf

[Service]
RestartSec=5s
StartLimitIntervalSec=0

# 저장 후 아래 명령어 실행
sudo systemctl daemon-reload
sudo systemctl restart docker.socket
sudo systemctl status docker.service
# 안되면 시스템 리붓
sudo reboot

 

반응형