I am trying to run a docker container which will allow me to have access to Docker daemon of the host machine (Docker outside of Docker approach). I am planning to run this container in a specific docker network and access the docker daemon via a port (2375 etc.). But when try the command (without specific network for the sake of simplicity) I get the following error:
# docker run --rm -v /var/run/docker.sock:/var/run/docker.sock docker:latest
Certificate request self-signature ok
subject=CN = docker:dind server
/certs/server/cert.pem: OK
Certificate request self-signature ok
subject=CN = docker:dind client
/certs/client/cert.pem: OK
ip: can't find device 'ip_tables'
ip_tables 28672 2 iptable_nat,iptable_filter
x_tables 40960 7 xt_nat,xt_tcpudp,xt_conntrack,ipt_MASQUERADE,xt_addrtype,iptable_filter,ip_tables
modprobe: can't change directory to '/lib/modules': No such file or directory
mount: permission denied (are you root?)
Could not mount /sys/kernel/security.
AppArmor detection and --privileged mode might break.
mount: permission denied (are you root?)
Adding --privileged
parameter doesn't work. On the other hand the below command seems to be working fine:
# docker run --rm -v /var/run/docker.sock:/var/run/docker.sock docker:latest version
Client:
Version: 23.0.5
API version: 1.42
Go version: go1.19.8
Git commit: bc4487a
...
How can I run this container to listen to a port for docker commands instead of running it for a custom command?
P.S. My main goal is to run this container using a compose file but posted the question with a single run command, again for simplicity.