Docker within docker privileged mode for web app hosting

Apparently, HF spaces does have plans to support docker-compose, as discussed in this thread.

This is an issue, as I want to test if I could deploy an already containerized web solution through Hugging Face, for pure demo purposes - to showcase the web solution and some AI models on medical images.

As HF spaces did not support docker-compose, I figured I might get around the issue by going for a docker-within-docker approach. However, to run docker-compose inside the Dockerfile, which is required and expected by the HF space for deployment, I’m running into some issues. I became aware of some limitations with said approach. To access and run docker commands from within docker, I will need to launch the original docker container by:

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

As I doubt that HF spaces has this by default, I guess this is not viable. Alternatively, if the original container is spawned in privileged mode, I wouldn’t need to do the docker.sock approach:

docker run --privileged -d --name dind-test docker:dind

But then again, I doubt HF spaces do any of these. Are there any other workaround I am not seeing?

My project is hosted at:

hi @andreped this is very cool! I’m going to loop @XciD and @chris-rannou here and see if they can tell us if that’s possible.

1 Like

Note that to deploy locally, you can simply do:

git clone https://github.com/andreped/dsa4hf
cd dsa4hf/dsa/
docker-compose pull
DSA_USER=$(id -u):$(id -g) docker-compose up

In essense, this is what I want to get working on HF spaces. If I manage to find a solution to this, there are also other web apps I could do the same fix for, so a workaround to this problem would be great :]