在移除 python2 之後 docker-compose 除錯

 其實要是不手賤可以不用這麼麻煩,因為大部份的時間用的是 python3 但是,裝的時侯沒注意,裝了 python2 和 python3 而預設的 pip 用的是 python2 ,在移除了 python2 之後,原本作動得好好的 docker container 不動了。

 症狀:

Traceback (most recent call last):
File "urllib3/connectionpool.py", line 677, in urlopen
File "urllib3/connectionpool.py", line 392, in _make_request
File "http/client.py", line 1252, in request
File "http/client.py", line 1298, in _send_request
File "http/client.py", line 1247, in endheaders
File "http/client.py", line 1026, in _send_output
File "http/client.py", line 966, in send
File "docker/transport/unixconn.py", line 43, in connect
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "requests/adapters.py", line 449, in send
File "urllib3/connectionpool.py", line 727, in urlopen
File "urllib3/util/retry.py", line 403, in increment
File "urllib3/packages/six.py", line 734, in reraise
File "urllib3/connectionpool.py", line 677, in urlopen
File "urllib3/connectionpool.py", line 392, in _make_request
File "http/client.py", line 1252, in request
File "http/client.py", line 1298, in _send_request
File "http/client.py", line 1247, in endheaders
File "http/client.py", line 1026, in _send_output
File "http/client.py", line 966, in send
File "docker/transport/unixconn.py", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "docker/api/client.py", line 205, in _retrieve_server_version
File "docker/api/daemon.py", line 181, in version
File "docker/utils/decorators.py", line 46, in inner
File "docker/api/client.py", line 228, in _get
File "requests/sessions.py", line 543, in get
File "requests/sessions.py", line 530, in request
File "requests/sessions.py", line 643, in send
File "requests/adapters.py", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "bin/docker-compose", line 3, in
File "compose/cli/main.py", line 67, in main
File "compose/cli/main.py", line 123, in perform_command
File "compose/cli/command.py", line 69, in project_from_options
File "compose/cli/command.py", line 132, in get_project
File "compose/cli/docker_client.py", line 43, in get_client
File "compose/cli/docker_client.py", line 170, in docker_client
File "docker/api/client.py", line 188, in init
File "docker/api/client.py", line 213, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

 工作環境:
    ubuntu Server 18 LTS
      python2, python3, pip, pip3
      docker, docker-compose


 排除:

  sudo usermod -aG docker $USER
  sudo reboot
  sudo systemctl start docker
  sudo systemctl enable docker

可能還會遇到:

  Failed to enable unit: Unit file /etc/systemd/system/docker.service is masked. 

  Failed to start docker.service: Unit docker.service is masked.

  service(systemctl) status docker 一下,看一下 docker 的狀態(當時沒做)

  sudo service docker start
  systemctl unmask docker.service
  systemctl unmask docker.socket
  systemctl start docker.service

一直找不到 docker, docker.service, docker.socket ,系統還一直要授權給多個 user 問了 user 的密碼

用 pip3 裝 docker, docker-compose 無用

重新 sudo apt install docker.io 

檢查一下:

systemctl list-unit-files docker.socket docker.service 

(sudo )service docker start

重新 docker-compose up -d

OK 了!

手真的是……以後還真別亂裝程式,裝了就別亂移除了,以免亂流。

 

收工!










留言

這個網誌中的熱門文章

使用 Excel 計算2個地點之間的直線距離

LINE 儲存的檔案傳到 email 不方便 很不方便 非常不方便 但是有解的筆記

Excel 巨集合併多個 Excel 檔案