osrf / rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.
Apache License 2.0
533 stars 68 forks source link

Add extension to support docker from docker #269

Open tfoote opened 4 months ago

tfoote commented 4 months ago

Not Docker in Docker but mounting the docker socket inside to enable calling the host daemon from inside

Following https://stackoverflow.com/a/33003273/604099

I've tested it working manually with just the docker socket mount.

rocker --volume /var/run/docker.sock:/var/run/docker.sock -- ros:rolling

miguelprada commented 4 months ago

I've been using this approach for some time without much issue in my extension. Note that one also installs the docker CLI inside the container, which may or may not be a desired feature.

One thing one needs to be somewhat careful about when doing this is bind mounts. Since the daemon is running on the host, you can only bind mount folders from the host filesystem, not folders from the filesystem inside the container. This has already bitten me a couple of times until I realized what was going on.

tfoote commented 4 months ago

Thanks for the validation and warnings. Those are good insights about the mounting restrictions. I wonder if there's a way to help make that more visible when inside. And installing docker into the container is defintely a good idea if possible.

As well the docker group pass through would be good to do automatically.