0

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.

ybalcanci
  • 93
  • 1
  • 7
  • 1
    Are you just trying to proxy the host's Docker Unix socket to a TCP port in the container space? There are some recipes around using `socat` to do this and you might try to put one of those in a container. For the setup you're describing you don't want a second Docker daemon. – David Maze May 05 '23 at 14:27
  • @DavidMaze exactly. I'll look into `socat` , thanks. – ybalcanci May 05 '23 at 14:47

0 Answers0