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:
- MacOS Desktop Docker: 4.13.0 (89412)
- Kubernetes: v1.25.2
- 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
The solution was to set the variable DOCKER_HOST before launching the
skaffold dev
command: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 :
Use your default docker context :
and check that you indeed changed the context with :
now check if your docker client can find the docker daemon :
if you have no errors good to run your skaffold dev
you can also specify to skaffold to use the docker CLI: