nestybox / sysbox

An open-source, next-generation "runc" that empowers rootless containers to run workloads such as Systemd, Docker, Kubernetes, just like VMs.
Apache License 2.0
2.78k stars 152 forks source link

docker-py does not seem to have access to the `docker daemon` inside a docker. #133

Closed JoanFM closed 3 years ago

JoanFM commented 3 years ago

Issue Hello,

I am interesting on maybe using sysbox to have Docker-In-Docker capabilities.

I have installed the runtime as specified in the README and then when running an image with this runtime, I try to run the following python command (with docker-py SDK).

import docker
env = docker.from_env()

and I get the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/docker/client.py", line 101, in from_env
    **kwargs_from_env(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/docker/client.py", line 45, in __init__
    self.api = APIClient(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
  File "/usr/local/lib/python3.7/site-packages/docker/api/client.py", line 222, in _retrieve_server_version
    'Error while fetching server API version: {0}'.format(e)
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))

It seems that it is failing to access the docker daemon.

What is the proper way to have docker in docker using sysbox?

Thank you!

ctalledo commented 3 years ago

Hi @JoanFM, thanks for giving Sysbox a shot, we hope you find it very useful.

Inside the Sysbox container, you should be able to run Docker just as you would on a bare-metal host or VM.

I would start by trying the Docker-in-Docker examples in the Sysbox Quickstart guide: https://github.com/nestybox/sysbox/blob/master/docs/quickstart/dind.md

This will give you a baseline understanding of how it works.

Depending on the image you used for the Sysbox container, you may need to start Docker manually inside the container (unless the image's entrypoint starts Docker for you). Have you checked if Docker is running correctly inside the container?

ctalledo commented 3 years ago

Closing as this was a query and a response has been provided.