skip to Main Content

I get the following message when I run the skaffold dev command:

Build Failed. Cannot connect to the Docker daemon at unix:
///var/run/docker.sock. Check if docker is running.

Tools versions:

  1. MacOS Desktop Docker: 4.13.0 (89412)
  2. Kubernetes: v1.25.2
  3. Skaffold: v2.0.0

Docker runs correctly in fact I can create resources on the cluster and create containers with the docker-cli commands. I successfully launch both docker info and docker version.

The command /Applications/Docker.app/Contents/MacOS/com.docker.diagnose check

reports

"No fatal errors detected."

(all tests pass).

I also tried setting the DOCKER_HOST variable:
DOCKER_HOST = /Users/<my folder>/.docker/run/docker.sock skaffold dev

Result:

invalid skaffold config: error getting docker client: unable to parse docker host `/Users/<my folder>/.docker/run/docker.sock`

My Skaffold.yaml file

apiVersion: skaffold/v3
kind: Config
metadata:
  name: test
build:
  local:
    push: false
  artifacts:
    - image: <myimage>
      context: <folder>
      docker:
        dockerfile: Dockerfile
manifests:
  rawYaml:
    - infra/k8s/deployment.yaml

How can I solve?

2

Answers


  1. Chosen as BEST ANSWER

    The solution was to set the variable DOCKER_HOST before launching the skaffold dev command:

    DOCKER_HOST="unix:///Users/<you>/.docker/run/docker.sock" skaffold dev
    

  2. The Docker Api use the docker.sock to communicate with the docker engine, that allow you to run commands like docker run myimage

    Usually the docker.sock is located at /var/run/docker.sock when you use docker-ce or docker.io.
    I see that you are using a desktop version of docker, so the paths are not the same anymore. and thats why skaffold can’t find the docker daemon.

    I am on Ubuntu so i found it at /home/<you>/.docker/desktop/docker.sock

    When you got the path you have to create a link :

    sudo ln -sf /home/<you>/.docker/desktop/docker.sock /var/run/docker.sock
    

    Use your default docker context :

    docker context use default 
    

    and check that you indeed changed the context with :

    docker context ls
    

    now check if your docker client can find the docker daemon :

    docker ps -a
    

    if you have no errors good to run your skaffold dev

    you can also specify to skaffold to use the docker CLI:

    build:
      local:
        push: false
        useDockerCLI: true
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search