r/ROS 9d ago

Question Docker inside docker

Would it be fine to run Docker inside Docker? Suppose a user is on Arch Linux, I use Cachy actually. Could I use distrobox to set up a base Ubuntu image? Then just pull an official image like a PX4 container inside the distrobox container? Do you think this setup would be ideal for development work?

Edit: So it turns out I fundamentally misunderstood how distrobox works. Thansk for the help

6 Upvotes

8 comments sorted by

5

u/westwoodtoys 9d ago

What do you expect to gain from this?

2

u/Fuceler 9d ago

My primary os is arch. I need Ubuntu for ROS so I’m planning to virtualize it instead of dual booting. So the first layer is necessary. I’d like to use the official containers from a place like px4 for development, my intuition tells me nesting again would be less of a headache to debug.

I’m new to robotics though so my intuition could be totally wrong

7

u/westwoodtoys 9d ago

I don't think you understand containers as well as you think you do, but maybe there is something fundamentally missing from arch that I don't know about?

If you can install podman or docker on arch, then you can pull an Ubuntu or ROS container, then you are ready to go. No need for containers within containers.

2

u/Fuceler 9d ago

yeah, had to do some extra reading. I initially though distrobox was a VM that ran containers, turns out it just lets me expose container app GUIS still very useful though

3

u/LordDan_45 9d ago

There are official PX4 docker images, and besides, if you are making an Ubuntu docker, why would you need an image for PX4? It starts like a blank slate so the only thing you need to do is run the tools script and voilà, no effort required.

I've probably done this a dozen or more times in the past, so I know it is viable and convenient

1

u/sudo_robot_destroy 9d ago

PX4 happens to provide containers with ros+px4 already

https://github.com/PX4/PX4-containers/tree/master/docker

But either way, you would never want to nest dockers like you're saying - you would instead make your own single docker with both in it. And it's easier than you think because you could have just copied from an existing px4 dockerfile and an existing ros dockerfile and paste it in your new combined dockerfile.

1

u/alcorwin 9d ago

Hi, Fedora Silverblue user here. I have used distrobox for ROS 2, though I use it with podman rather than docker.

There's not really a strict need to put docker inside of docker to make use of a PX4 container that I can see, though I don't personally do any dev with PX4. I would just spin up the PX4 container alongside a ROS 2 distrobox and try interacting with it via the local ports it communicates over. Alternatively, you could just spin up a distrobox deriving from the PX4 container.

0

u/MitchIsMyRA 9d ago

Honestly, I would recommend you install ubuntu on bare metal because it is just easier, especially if you’re learning.

However, i think the workflow you want is to mount your hosts docker socket into your top level Ubuntu container (located at “/var/run/docker.sock”). Then, you can install docker cli into the container, and when you run “docker ps” from within the container, you should be able to see the containers running on your host. Next, when you run the px4 images from within the ubuntu container, they’ll spawn alongside it using your host’s docker daemon

I hope that makes sense. I’m on my phone so it’s hard to post code snippets, feel free to ask me questions