I'm launching a container which runs a bash script that does a docker build internally using docker 1.3.2 on Centos 7.0.1406 . The files/commands are at https://gist.github.com/wrabbit-revisited/1d70d0f1805be1848c08 .
The docker build needs access to the docker socket so i use a common trick, as per http://nathanleclaire.com/blog/2014/07/12/10-docker-tips-and-tricks-that-will-make-you-sing-a-whale-song-of-joy/ :
-v /var/run/docker.sock:/var/run/docker.sock
Prior to the build i run a check in the script:
if [ -e "/var/run/docker.sock" ];
then
echo "docker.sock found"
else
echo "docker.sock not found"
fi
and the "echo" shows that docker.sock is not found. It is found if the check is done outside the container using sudo.
I tried adding "--permissive=true" to the "docker run" command line, but no apparent change.
There is some reference to a similar problem here: https://github.com/dpw/selinux-dockersock . It targets Fedora/RHEL, but doesn't resolve this issue, either. If i use "setenforce Permissive" and sestatus to ensure selinux is in permissive mode the issue remains unresolved.
I've also tried adding "--security-opt=label:type:docker_t" to the docker command line, as per https://github.com/jwilder/nginx-proxy/issues/40 . No apparent effect.
The selinux policy for Docker is described here: http://www.unix.com/man-page/centos/8/docker_selinux/ .
Lots of information, but i'm not sure if selinux is contributing to the problem. If i edit /etc/selinux/config to disable selinux then reboot and run sestatus it says selinux is disabled, but the issue remains.
Looking about, it may be related to this: https://github.com/docker/compose/issues/983 . Using this trick to run docker inside a container is quite common but perhaps there is a better way to do this or a good workaround. I considered dind, but that's work and this is a widely-used, simple (on the surface), approach to running a docker build inside a container. There is probably a simple solution.
Any help would be appreciated! thanks
--privileged
flag. It's a bit of a sledgehammer and I'd be glad to learn about a better approach.