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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. “docker network” Command Examples
  2. Bash if loop examples (if then fi, if then elif fi, if then else fi)
  3. What are Shell Scripts? How to Create Shell Scripts?
  4. fluxctl: Command-line tool for Flux v1
  5. Shell Script to print pyramid of Stars
  6. Beginners Guide to Using “trap” to Catch Signals and Handle Errors in Shell Script
  7. A Beginner’s Guide To Create Files & Folders Inside Windows Subsystem For Linux
  8. kubectl: command not found
  9. 2to3 – Automated Python 2 to 3 code conversion
  10. crictl: Command-line for CRI-compatible container runtimes

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright