mounting /var/run/docker.sock

Can I configure the following to be able to execute a docker run from inside a container? Running balenaOS with several containers…

[The] simplest way is to just expose the Docker socket to your CI container, by bind-mounting it with the -v flag.

Simply put, when you start your CI container (Jenkins or other), instead of hacking something together with Docker-in-Docker, start it with:

docker run -v /var/run/docker.sock:/var/run/docker.sock ...

Now this container will have access to the Docker socket, and will therefore be able to start containers. Except that instead of starting “child” containers, it will start “sibling” containers.

BalenaOS does not support bind mounts – you’ll have to use volumes. Is this a balenaCloud-managed device? If so, to expose balenaEngine’s socket inside your container you’ll need to add the “io.balena.features.balena-socket” label 1 to the appropriate service definition in your compose file.