Docker Community Forums

Share and learn in the Docker community.

Cannot connect to the Docker daemon although it seems to be running

Description of Issue

I’m attempting to install Docker on a Red Hat virtual machine. I’m new to setting up Docker engine and not an expert in Red Hat, so its possible my problem here is a knowledge gap- apologies if that’s the case and thanks for any help+advice.

I followed the instructions listed here: Install Docker Engine on CentOS | Docker Documentation
If I understand correctly, Red Hat and Cent OS are similar enough that I should be able to install from these instructions.
After following the instructions, I’m getting the following error when I attempt to run hello-world after starting the Docker service (note, the service seems to start successfully, status output listed later):

sudo systemctl start docker
sudo docker run hello-world

Error:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

I’ve tried a bunch of various suggestions from forums (including completely uninstalling, removing all Docker directories, and reinstalling), but none seem to fix the issue.
If I run sudo dockerd or sudo dockerd --debug in one terminal window and then run sudo docker run hello-world from another, it executes successfully (pulls the repo, executes, gives me a success message)

sudo dockerd
$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

I’m not sure if this is a routing issue or a firewall issue (or a lack of knowledge issue).

System Information and Environment Description

Environment

I’m running this on a Red Hat machine maintained within a corporate network; the network infrastructure is fairly tightly maintained by our IT department. I’m not sure if that matters for connecting from inside the server to itself, as I assume the hello-world run via the service operates similarly to running it against dockerd, but I’m not really sure of that.

I’ve erred on the side of caution and removed anything I think might be sensitive information and marked it with [REMOVED].

OS Version

$ uname -r
3.10.0-1160.11.1.el7.x86_64
$ cat /etc/os-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.9 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.9"
PRETTY_NAME="Red Hat Enterprise Linux"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.9:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.9
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.9"
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)

Docker Status

$ systemctl status docker.service -l
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-05-24 22:52:30 UTC; 16h ago
     Docs: https://docs.docker.com
 Main PID: 19549 (dockerd)
    Tasks: 26
   Memory: 39.8M
   CGroup: /system.slice/docker.service
           └─19549 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.106980017Z" level=warning msg="Base device already exists and has filesystem xfs on it. User specified filesystem  will be ignored." storage-driver=devicemapper
May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.128499345Z" level=info msg="[graphdriver] using prior storage driver: devicemapper"
May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.128576273Z" level=warning msg="[graphdriver] WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release"
May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.140400924Z" level=info msg="Loading containers: start."
May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.437636251Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.540966991Z" level=info msg="Loading containers: done."
May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.568254829Z" level=info msg="Docker daemon" commit=8728dd2 graphdriver(s)=devicemapper version=20.10.6
May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.568448596Z" level=info msg="Daemon has completed initialization"
May 24 22:52:30 [REMOVED] systemd[1]: Started Docker Application Container Engine.
May 24 22:52:30 [REMOVED] dockerd[19549]: time="2021-05-24T22:52:30.621259764Z" level=info msg="API listen on /var/run/docker.sock"

Docker Info

$ sudo docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  scan: Docker Scan (Docker Inc.)

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info

Docker Repos

Not sure if this is helpful, but figured I’d include it anyway

$ yum list docker-ce
Loaded plugins: enabled_repos_upload, langpacks, package_upload, product-id, search-disabled-repos, subscription-manager
Installed Packages
docker-ce.x86_64                                         3:20.10.6-3.el7                                          @docker-ce-stable
Uploading Enabled Repositories Report

Steps to Reproduce

  1. Install RHEL 7.9
  2. Follow instructions to install Docker: Install Docker Engine on CentOS | Docker Documentation
  3. Attempt to run hello-world referenced in install instructions

Any suggestions on what the issue might be or how to tackle it are much appreciated! Also if I can provide any more information, please let me know.
Hoping its an easy fix that I’m just struggling to figure out.