在 docker-容器中调用 docker

Call docker in docker-container

我docker-写得像

myservice:
   tty: true
   restart: on-failure
   container_name: myname
   volumes:
      - /var/run/docker.sock:/var/run/docker.sock
   env_file:
      - env_file
   ports:
      - "7777:7777"

为什么 docker ps 例如不能在容器中工作?

关于您对我的评论的回答(docker 未安装在您的容器中)这是我的工作解决方案:

FROM <<YOUR_DOCKER_BASE_IMAGE>>

# Docker Compose installation for "Build / Container" stage
# https://medium.com/@schogini/running-docker-inside-and-outside-of-a-jenkins-container-along-with-docker-compose-a-tiny-c908c21557aa

USER root

RUN apt update -y
RUN apt install -y curl
RUN curl https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz | tar xvz -C /tmp/ && mv /tmp/docker/docker /usr/bin/docker

# Customize here your container...

PS: 如您所写,/var/run/docker.sock 是强制性的。