LoginSignup
1
2

More than 5 years have passed since last update.

Docker runで「getsockopt: connection refused」

Last updated at Posted at 2017-10-30

開発環境

  • Ubuntu 16.04
  • Docker 17.09.0-ce
  • プロキシサーバ利用

エラー内容

console
$ sudo su -
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp xxx.xxx.154.207:443: getsockopt: connection refused.
See 'docker run --help'.

原因

Dockerにプロキシサーバを設定していない場合、上記の接続エラーになる

対応手順

Dockerにプロキシサーバーを設定

console
# docker.service.dを作成してproxy設定を記述
$ mkdir /etc/systemd/system/docker.service.d
$ vi /etc/systemd/system/docker.service.d/http-proxy.conf

    [Service]
    Environment="HTTP_PROXY=http://proxy.example.com:80/"
    Environment="NO_PROXY=localhost,127.0.0.0/8"

# reloadして設定内容を確認したらrestart
$ systemctl daemon-reload
$ systemctl show --property Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/ NO_PROXY=localhost,127.0.0.0/8
$ sudo systemctl restart docker

設定したらもう一度docker runして確認

console
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
5b0f327be733: Pull complete
Digest: sha256:07d5f7800dfe37b8c2196c7b1c524c33808ce2e0f74e7aa00e603295ca9a0972
Status: Downloaded newer image for hello-world:latest

Hello from Docker! 

補足

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2