安装了Docker引擎的Jenkins JDK 11中的Docker文件-无法连接到Docker守护程序

htrmnn0y  于 2022-11-02  发布在  Jenkins
关注(0)|答案(1)|浏览(268)

我已经创建了一个基于jenkins/jenkins:lts-jdk11的Dockerfile
我试图安装docker + docker组成,以便Jenkins将有机会访问这个当我创建我的管道为CD/CI。
下面是我的Dockerfile:

FROM jenkins/jenkins:lts-jdk11 AS jenkins

WORKDIR /home/jenkins

RUN chown -R 1000:1000 /var/jenkins_home

USER root

# Install aws cli version 2

RUN apt-get update && apt-get install -y unzip curl vim bash sudo
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip
RUN ./aws/install

# Install docker cli command

RUN sudo apt-get update
RUN sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN sudo apt-get update
RUN sudo apt-get install -y docker-ce docker-ce-cli containerd.io

## Install docker compose

RUN mkdir -p /usr/local/lib/docker/cli-plugins
RUN curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
RUN chmod +x /usr/local/lib/docker/cli-plugins/docker-compose

RUN sudo usermod -a -G docker jenkins

Docker命令在容器中运行良好,但一旦我开始构建映像,它就会显示此错误:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
如果我尝试使用service docker start启动Docker服务,则会出现以下错误:
mkdir: cannot create directory ‘cpuset’: Read-only file system
我不知道如何解决这个问题。
短暂性脑缺血

rqdpfwrv

rqdpfwrv1#

容器未使用init系统。因此无法启动Docker服务。

相关问题