vm31
vm31

Reputation: 179

Docker unable to start a container

Until yesterday I had docker -v 17 and today I have docker -v 18 with which when I do docker run container does not start but it is in Exit state.

Following are the command that I used:

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

Does not start the container. And whatever I do I am not able to start my container.

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 file

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

Note: when I removed CMD: 'npm start' at the bottom of my dockerfile. I was able to start container inactive state

Upvotes: 0

Views: 651

Answers (3)

vm31
vm31

Reputation: 179

when i removed CMD: 'npm start' at the bottom of my dockerfile. I was able to start container in active state

Upvotes: 0

Mike Doe
Mike Doe

Reputation: 17566

Like suggested it turns out the volume was corrupted, so the solution is simple:

docker volume rm jenkins-data

before running the container again.

Upvotes: 0

Fendi jatmiko
Fendi jatmiko

Reputation: 2895

i'm suspecting its a permission issue. .try to create the jenkins_home directory in the current directory prior to running the docker command above.

Upvotes: 1

Related Questions