Search code examples
dockerminikubedocker-build

Why docker-daemon is not accessible in minikube VM?


I have installed minikube and started it with it's default virtual machine so basically started the minikube with minikube start. In minikube vm which i have accessed through minikube ssh i am trying to build my dockerfile after mounting the local file system but it's showing error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I checked the ActiveState of docker through systemctl show --property ActiveState docker and it's showing failed but the docker version is showing me all the normal details like version built etc.

This is the statement that i am trying to execute : $ sudo docker build --file=Dockerfile --tag=demo-backend:latest --rm=true .

Should i install docker seperatley and if not how should access docker in VM which is already present in my system


Solution

  • It looks like somehow docker has not started properly.

    Please try to execute sudo systemctl start docker and let me know if that was the issue.

    EDIT: Adding more info from the comments in order to supplement the answer:

    I had to set the docker environment variable to local instance of docker running in minikube through this command: eval $(minikube docker-env) and then restart the docker and all of this has to done in the same shell in which i aim to access the docker otherwise it does not works. this made me acces the docker from minikube – rehan