1

I installed Jenkins in a Docker container and it does not run automatically. I have to run /etc/init.d/jenkins start . Then all are smooth and nice. All the tutorials that I have followed say that after installation it should run by default , but it doesn't.

Any thoughts?

Wosi
  • 41,986
  • 17
  • 75
  • 82
Kostas Demiris
  • 3,415
  • 8
  • 47
  • 85

2 Answers2

2

If you like at the Dockerfile of the various Jenkins images (like the official _/jenkins one), you will see why jenkins "runs automatically":

COPY jenkins.sh /usr/local/bin/jenkins.sh
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]

(tini is a script to adopt zombie processes, which is an issue I presented before in "Use of Supervisor in docker")

So it depends on the ENTRYPOINT of your Dockerfile: it should include the right command to start Jenkins.


Also you can either use supervisor or entrypoint in your docker file.

No need to use supervisor: that is what tini is for in the official image.

If I use the official jenkins image, which is configured to run jenkins automatically, I suppose I could install Locustio and start it with 'docker exec' afterwards, right?

You wouldn't install Locusto in the same image, or you wouldn't use docker exec to run it in the Jenkins container (docker exec is for opening a session mainly for debug purpose)

You would use a Locust.io image to run a second container.
If jenkins needs locust.io, you could run locust.io first, then run jenkins with --link directive.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks VonC, I read the answer you mention, but I cannot admit that I fully understood it as I do not master Docker and it's inner works just yet. I created my container from ubuntu:latest and built it component by component. I want one container to encapsulate Jenkins for CI and Locustio (load testing) server. Should I use an official container if I understand correctly? By specifying an ENTRYPOINT dont I limit the container to run one service? Should I run the 2 services in separate containers? – Kostas Demiris Oct 14 '15 at 17:24
  • That is why seeing your Dockerfile would help here – VonC Oct 14 '15 at 17:29
  • @KostasDemiris Right. The idea is to use a Dockerfile, in order to achieve a reproducible result (the same image for each docker build). See https://docs.docker.com/reference/builder/ – VonC Oct 14 '15 at 19:30
  • @KostasDemiris I have edited my answer to address your questions. – VonC Oct 14 '15 at 19:35
  • Ok I understand that having one application per container is the right way, right? I should rethink my architecture if this is best practice. I wanted to build a container (for each one of several developers) that would include locust and then fetch each developers code (load tests) from github , via Jenkins. Should I essentially use 2 containers for each developer? Also, I run 'docker exec -d container-name /etc/init.d/jenkins start' and worked perfectly.... – Kostas Demiris Oct 14 '15 at 20:17
  • @KostasDemiris using docker exec is just a way to attach oneself to a running container, it is not the right way to trigger processes. The goal is to have a `docker-compose up` which launches all the containers (here 2) with them running directly the right process. See https://docs.docker.com/compose/. – VonC Oct 14 '15 at 20:19
  • @KostasDemiris It is better to have one (or very few) process per container: that increase isolation between processes, facilitate debug per container (because one or few processes are running in said container), and ease the stop/kill process management (that I mention in http://stackoverflow.com/a/33119321/6309) – VonC Oct 14 '15 at 20:20
  • After taking into consideration your comments I will use 2 containers (jenkins/locust) both of which will mount a common volume where jenkins will build any new code to then be used by locust.The two containers don't even need to be linked. I am too early in this project to know the rights and wrongs so I will follow the best practices – Kostas Demiris Oct 18 '15 at 14:10
0

Simple is to use official image of jenkins on docker hub. Also you can either use supervisor or entrypoint in your docker file.

Abhijeet Kamble
  • 3,131
  • 2
  • 30
  • 36
  • If I use the official jenkins image, which is configured to run jenkins automatically, I suppose I could install Locustio and start it with 'docker exec' afterwards, right? I have no exposure to Supervisor. If it is needed I could easily pick it up if you could provide me with a nice link. Thanks – Kostas Demiris Oct 14 '15 at 19:24
  • First thing first.. You can install anything in it. Run your jenkins docker with volume mountinh to /var/lib/jenkins to your host and install plugins what you want. For next time when you again create your container it will have the same settings with all plugins installed already. – Abhijeet Kamble Oct 15 '15 at 02:12