I want to run docker:dind
and get a shell.
If I run docker run --privileged docker:dind sh
it just exit.
The workaround is to run: docker run -d --privileged docker:dind
it starts in the background and then I can run docker exec -it <container> sh
and get a shell.
But I want that it will start with a shell.
I created a Dockerfile:
FROM docker:dind
ENTRYPOINT sh
I built it:docker build -t dind2 -f Dockerfile .
When I run docker run --rm -it --privileged dind2
I get a shell but when I tried to run simple container docker run busybox echo hi
it failed with:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
Any idea how make docker:dind
start with a shell without the workaround of running it in the background and then using exec
to get a shell.
Just like Andreas Wederbrand said. you can just
docker run -it docker:dind sh
and if you want to use Dockerfile. Just write like this.
FROM docker:dind
CMD ["sh"]
It shouldn't overwrite ENTRYPOINT
. You can try to inspect docker:dind
image.
docker inspect docker:dind
you can see entrypoint is a shell script file.
"Entrypoint": [
"dockerd-entrypoint.sh"
],
of course, we can find this file in container. get inside the docker
docker run -it docker:dind sh
and then
cat /usr/local/bin/dockerd-entrypoint.sh
more about entrypoint you can see
https://medium.freecodecamp.org/docker-entrypoint-cmd-dockerfile-best-practices-abc591c30e21
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With