Skip to content

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? #35256

@ghost

Description

Normally if you get this error message:

panic: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

it means that you need to start your docker daemon since it is not running.

My docker daemon is running from what I can tell. I can run docker commands like docker info, docker ps.

I created a swarm and ssh'ed into the manager.
docker info:

Containers: 3
 Running: 2
 Paused: 0
 Stopped: 1
Images: 3
Server Version: 17.10.0-ce
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 25
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: <node_id>
 Is Manager: true
 ClusterID: <cluster_id>
 Managers: 1
 Nodes: 4
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: *.*.*.*
 Manager Addresses:
  *.*.*.*:*
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 0351df1c5a66838d0c392b4ac4cf9450de844e2d
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.4.93-boot2docker
Operating System: Boot2Docker 17.10.0-ce (TCL 7.2); HEAD : 34fe485 - Wed Oct 18 17:16:34 UTC 2017
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.8MiB
Name: master01
ID: ..................
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 54
 Goroutines: 193
 System Time: 2017-10-20T06:54:48.585548026Z
 EventsListeners: 2
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox
Experimental: true
Insecure Registries:
 *.*.*.*/*
Live Restore Enabled: false

I created a service in the swarm that runs main.go which is just the example client in the readme:

package main

import (
	"context"
	"fmt"

	"github.com/docker/docker/api/types"
	"github.com/docker/docker/client"
)

func main() {
	cli, err := client.NewEnvClient()
	if err != nil {
		panic(err)
	}

	containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
	if err != nil {
		panic(err)
	}

	for _, container := range containers {
		fmt.Printf("%s %s\n", container.ID[:10], container.Image)
	}
}

But it gives me an error that the service can not connect to the Docker daemon at unix:///var/run/docker.sock.

If I run a curl command to get all the services I get the expected response:

curl -X GET --unix-socket /var/run/docker.sock http://localhost/services

But running the client does not work.
Any idea what the cause might be?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions