Microk8s: Microk8s should expose the docker agent to allow for local builds

Created on 28 May 2018  Â·  7Comments  Â·  Source: ubuntu/microk8s

Hi all,

Microk8s should expose the docker agent to allow for local container builds using the daemon included inside the snap, I.E:

microk8s.docker build .
microk8s.docker login someregistry.catloverextreme.com

Etc.

Cheers,

  • Calvin
enhancement

Most helpful comment

Can confirm this works for at least getting the Docker client talking to the internal daemon. Worth pointing out though that another slash is required

> docker -H unix:///var/snap/microk8s/current/docker.sock ps
root@other-k8s:/var/snap/microk8s/current# docker -H unix:///var/snap/microk8s/current/docker.sock ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS               NAMES
fedf8c9eb0e9        6c0dbeaa8d20                  "/pod_nanny --config…"   6 minutes ago       Up 6 minutes                            k8s_eventer-nanny_heapster-v1.5.2-577898ddbf-m868v_kube-system_0e11103f-8a47-11e8-9183-42010a800002_1

whereas without the additional /:

> docker -H unix://var/snap/microk8s/current/docker.sock ps
Cannot connect to the Docker daemon at unix://var/snap/microk8s/current/docker.sock. Is the docker daemon running?

Additionally one can use export DOCKER_HOST=unix:///var/snap/microk8s/current/docker.sock to avoid the -H argument on each command. It might also be worth doing sudo usermod -aG docker <username> (the socket should belong to group 'docker') so you don't have to be root.

All 7 comments

See also minikube doc here: https://kubernetes.io/docs/getting-started-guides/minikube/#reusing-the-docker-daemon

yes, I think a better option would be to have local docker client re-use
the docker daemon running from the snap

On Tue, May 29, 2018 at 7:13 AM Oliver Burkhalter notifications@github.com
wrote:

See also minikube doc here:
https://kubernetes.io/docs/getting-started-guides/minikube/#reusing-the-docker-daemon

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/juju-solutions/microk8s/issues/31#issuecomment-392740116,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAET1dEYsQfrnHnH-CeNc-I9-NfEgd2Dks5t3S1rgaJpZM4UQPj4
.

I agree with @marcoceppi I would like to use docker client and docker-compose on my laptop while microk8s is running. There should be a way to expose the microk8s docker daemon to other users on the machine.. would make image development faster and simplify tooling to not have to use special commands.

@bkcsfi you should already be able to do that by pointing your docker client to the socket the docker daemon is using.

docker -H unix://var/snap/microk8s/current/docker.sock

Can confirm this works for at least getting the Docker client talking to the internal daemon. Worth pointing out though that another slash is required

> docker -H unix:///var/snap/microk8s/current/docker.sock ps
root@other-k8s:/var/snap/microk8s/current# docker -H unix:///var/snap/microk8s/current/docker.sock ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS               NAMES
fedf8c9eb0e9        6c0dbeaa8d20                  "/pod_nanny --config…"   6 minutes ago       Up 6 minutes                            k8s_eventer-nanny_heapster-v1.5.2-577898ddbf-m868v_kube-system_0e11103f-8a47-11e8-9183-42010a800002_1

whereas without the additional /:

> docker -H unix://var/snap/microk8s/current/docker.sock ps
Cannot connect to the Docker daemon at unix://var/snap/microk8s/current/docker.sock. Is the docker daemon running?

Additionally one can use export DOCKER_HOST=unix:///var/snap/microk8s/current/docker.sock to avoid the -H argument on each command. It might also be worth doing sudo usermod -aG docker <username> (the socket should belong to group 'docker') so you don't have to be root.

In the edge and 1.11/edge channels you will now find the microk8s.docker command. This addition came in with the registry addon (microk8s.enable registry) that start an insecure registry at localhost:32000. Have a look here: https://github.com/ubuntu/microk8s/blob/master/docs/registry.md

Feel free to reopen this issue if you find something missing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xrpn picture xrpn  Â·  4Comments

alphawolf1988 picture alphawolf1988  Â·  3Comments

cnadeau picture cnadeau  Â·  4Comments

edsiper picture edsiper  Â·  5Comments

khteh picture khteh  Â·  5Comments