Docker on Kubernetes

2/21/2020

I have an application which needs docker and the application checks for docker deamon when it starts. I can not get away with this as it is a 3rd party application.

So, getting error when i tried to deploy this app on kubernetes.

Failed to run 'docker -H unix:///var/run/docker.sock ps -a': exited with status 1; stderr='Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I am not sure if kubernetes is internally using docker deamon for spinning up containers. Is there any way to get around with this?

Thanks

-- user1578872
docker
kubernetes

5 Answers

2/21/2020

kubernetes by default uses docker also as a container runtime, so this means you need a docker within docker. it is possible generally, but needs some extra configuration and privileges. start with this official docker blog article which should give you some pointers how to achieve it.

-- morgwai
Source: StackOverflow

2/24/2020

There are two ways to run Docker in the Kubernetes application.

DOOD

Docker Out Of Docker. Here you have to mount host's /var/run/docker.sock on your container. It'll connect to the host's Daemon through it. But it is more vulnerable.

DIND

Docker IN Docker. It is a container that runs both Docker Daemon and Docker cli by itself. Here we don't need to mount /var/run/docker.sock into the container. More secure than DOOD.

-- hariK
Source: StackOverflow

2/21/2020

Kubernetes can run without docker, but the app you're running requires to connect to docker. Could you try to run it with docker desktop running?

-- Charlotte Zheng
Source: StackOverflow

2/24/2020

You can mount the docker socket file in your deployment.

docker container run -d \
-v /var/run/docker.sock:/var/run/docker.sock <image-name>

Similar changes can be added to Kubernetes deployment too.

Now, your application can connect with the docker daemon running in your local system.

However, it is not a good practice as it compromises the security isolations provided by docker.

-- Palash Goel
Source: StackOverflow

2/21/2020

Looks like is a docker-compose.yml and you need it. Now docker have a version with kubernetes and you dont have started/installed docker and if you want to use kubernetes in docker make sure is activiated kubernetes in your docker settings like this:

docker settings

-- Iromero
Source: StackOverflow