Unable to start container from jenkins

僤鯓⒐⒋嵵緔 提交于 2019-12-08 03:10:23

问题


In Jenkins I installed Docker build step plugin.
In Jenkins, created job and in it, executed docker command selected build image. The image is created using the Dockerfile.The Dockerfile is :

FROM ubuntu:latest


#OS Update
RUN apt-get update
RUN apt-get -y install git git-core unzip python-pip make wget build-essential python-dev libpcre3 libpcre3-dev libssl-dev vim nano net-tools iputils-ping supervisor curl supervisor

WORKDIR /home/wipro
#Mongo Setup
RUN curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-3.0.2.tgz && tar -xzvf mongodb-linux-x86_64-3.0.2.tgz && cd mongodb-linux-x86_64-3.0.2/bin && cp * /usr/bin/
#RUN mongod --dbpath /home/azureuser/CI_service/data/ --logpath /home/azureuser/CI_service/log.txt --logappend --noprealloc --smallfiles --port 27017 --fork

#Node Setup
#RUN curl -O https://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz && tar -xzvf node-v0.12.7.tar.gz && cd node-v0.12.7
#RUN cd /opt/node-v0.12.7 && ./configure && make && make install
#RUN cp /usr/local/bin/node /usr/bin/ && cp /usr/local/bin/npm /usr/bin/
RUN wget https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz
RUN cd /usr/local && sudo tar --strip-components 1 -xzf /home/wipro/node-v0.12.7-linux-x64.tar.gz
RUN npm install forever -g

#CI SERVICE
ADD prod /home//
ADD servicestart.sh /home/
RUN chmod +x /home/servicestart.sh
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["sh", "/home/servicestart.sh"]

EXPOSE 80
EXPOSE 27017

Then I tried to create the container and container is created.
When I tried to start the container, the container is not running.
When I checked with command:

docker ps -a

, it shows status as created only.
Its not in running or Exited state.

The output of docker ps -a is:

docker ps -a

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
8ac762c4dc84        d85c2d90be53        "sh /home/servi"   15 hours ago        Created                                 hungry_liskov
7d8864940515        d85c2d90be53        "sh /home/servi"   16 hours ago        Created                                 ciservice

How to start the container using jenkins?


回答1:


It depends on your container main command (ENTRPOINT + CMD)

A created state (for non data-volume container) means the main command failed to execute.
Try a docker logs <container_id> to see if there is any error message recorded.

CMD ["sh", "/home/servicestart.sh"] should be:

CMD ["/home/servicestart.sh"]

(The default ENTRYPOINT for Ubuntu should be ["sh", "-c"], so no need to repeat an "sh")



来源:https://stackoverflow.com/questions/35293195/unable-to-start-container-from-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!