直到昨天我有了docker -v 17,今天我有了docker -v 18,当我执行docker run容器时,它不会启动,但它处于退出状态。
以下是我使用的命令:
docker system prune -a
docker build .
docker run --name myjenkins -u root -d -p 8080:8080 -p 50000:50000 -v jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock --net=host <imageName>
docker ps -a
docker start myjenkins
不启动容器。 而且无论我做什么,我都无法启动容器。
npm ERR! path /var/jenkins_home/workspace/pipelineDemo@script/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/var/jenkins_home/workspace/pipelineDemo@script/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Docker文件
FROM jenkins/jenkins:lts
ENV JENKINS_SLAVE_AGENT_PORT '50000'
USER $USER
WORKDIR /var/jenkins_home/workspace/pipelineDemo@script
ARG NODE_ENV
ENV NODE_ENV=$NODE_ENV
RUN apt-get update
RUN curl -sL https://deb.nodesource.com/setup_9.x | bash -
RUN apt-get install -y nodejs
RUN apt-get update
RUN apt-get install -y npm
RUN npm install -g npm
RUN apt-get install python3
RUN apt-get install --reinstall make
RUN npm install --global gulp-cli
RUN npm install --global gulp
RUN apt-get -y install g++
RUN apt-get update
RUN apt-get install
RUN apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update
RUN apt-get install -y docker-ce
RUN curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
RUN chmod +x /usr/local/bin/docker-compose
COPY Jenkinsfile /var/jenkins_home/workspace/pipelineDemo@script
RUN usermod -aG docker jenkins
USER jenkins
注意:当我删除CMD时:dockerfile底部的'npm start'。我能够启动容器无效状态
答案 0 :(得分:1)
我怀疑是权限问题。 .p在运行上述docker命令之前,尝试在当前目录中创建jenkins_home
目录。
答案 1 :(得分:0)
就像建议的那样,结果表明卷已损坏,因此解决方案很简单:
docker volume rm jenkins-data
再次运行容器之前。
答案 2 :(得分:0)
当我删除CMD时:在dockerfile底部的'npm start'。我能够以活动状态启动容器