• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to resolve Docker Search Command Error – “getsockopt: no route to host” in CentOS / RHEL / Fedora

by admin

The Problem

When trying to search docker images under docker repository, returns with error below :

# docker search centos
Error response from daemon: Get https://index.docker.io/v1/search?q=oracle%2A: dial tcp 52.72.231.247:443: getsockopt: no route to host

The docker is engine is running fine.

# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2017-11-18 06:37:54 UTC; 4min 54s ago
     Docs: https://docs.docker.com
 Main PID: 1109 (dockerd)
   Memory: 72.6M
   CGroup: /system.slice/docker.service
           ├─1109 /usr/bin/dockerd
           └─1127 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/...

Also, SELinux is set to Permissive mode and iptables are allowed to have Docker traffic.

# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
Chain FORWARD (policy DROP)
target     prot opt source               destination         
DOCKER-USER  all  --  anywhere             anywhere            
DOCKER-ISOLATION  all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
Chain DOCKER (1 references)
target     prot opt source               destination         
Chain DOCKER-ISOLATION (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere            
Chain DOCKER-USER (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere
# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

Enabling proxy for Docker

For the Docker node to communicate with Docker hub, you need to have proxy enabled. This is required when you have an environment under the firewall. There are 2 ways in which this can be done.

Method 1

1. To configure web proxy networking options, create the drop-in file /etc/systemd/system/docker.service.d/http-proxy.conf that contains the following lines:

# vi /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=proxy_URL:port"
Environment="HTTPS_PROXY=proxy_URL:port"

2. Replace proxy_URL and port with the appropriate URLs and port numbers for your web proxy.

Method 2

1. Open the file /etc/sysconfig/docker using any editor and append the below two entries.

# vi /etc/sysconfig/docker
HTTP_PROXY="http://[proxy_IP].domain.com:80"
HTTPS_PROXY="http://http://[proxy_IP].domain.com:80"

2. Once completed start/stop the docker service

# systemctl stop docker
# systemctl start docker

Filed Under: DevOps, Docker

Some more articles you might also be interested in …

  1. How to install docker on CentOS / RHEL / Fedora
  2. Bash if loop examples (if then fi, if then elif fi, if then else fi)
  3. How to use “break” and “continue” statements in shell scripts
  4. EFS Mount Issue “Failed to resolve server: Name or service not known”
  5. How to use shell aliases in Linux
  6. Puppet Server’s Resources Cheat Sheet with Examples
  7. Beginners Guide to The Docker World
  8. How to Map Static IP to your Domain (with GoDaddy example)
  9. How to Use External Python modules in MySQL Shell
  10. ValueError: Masked arrays must be 1-D

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright