AWS ECS Plugin

1,066 views
Skip to first unread message

Brandon Wagner

unread,
Jan 21, 2016, 4:13:10 PM1/21/16
to Jenkins Users
I'm trying to use the Jenkins AWS EC2 Container Service (ECS) plugin to deploy Jenkins Slave Containers for builds. I have an ECS cluster setup, and I have it configured in my Jenkins Configuration. Everything appears to be good until I try to build a job, restricting to the ecs cloud label I setup, and it just comes back with "(pending—Jenkins-Container-Cloud-456...164is offline)" .  

Does anyone know how to fix this, or have suggestions on debugging steps? 

nicolas de loof

unread,
Jan 22, 2016, 7:12:07 AM1/22/16
to jenkins...@googlegroups.com
First look into jenkins logs.
Also check on ECS a task definition has been created for jenkins-slaves. 
Also double check ECS nodes can ping your jenkins master URL.

2016-01-21 22:13 GMT+01:00 Brandon Wagner <bmwag...@gmail.com>:
I'm trying to use the Jenkins AWS EC2 Container Service (ECS) plugin to deploy Jenkins Slave Containers for builds. I have an ECS cluster setup, and I have it configured in my Jenkins Configuration. Everything appears to be good until I try to build a job, restricting to the ecs cloud label I setup, and it just comes back with "(pending—Jenkins-Container-Cloud-456...164is offline)" .  

Does anyone know how to fix this, or have suggestions on debugging steps? 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f9bf24d9-a9e3-46f6-8fba-041b3344bdc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brandon Wagner

unread,
Jan 22, 2016, 2:46:50 PM1/22/16
to jenkins...@googlegroups.com
So I ended up figuring my issue out. I think there were a couple of issues. My JNLP port was set to 50,000 instead of 5,000 which the Jenkins Docker Container I was using was mapping to the host port 5000. And my Load Balancer in front of Jenkins was not forwarding port 5000 to the host (only 443). Anyways, all of that is fixed and I can now run builds on slaves in ECS.

My next problem: I want to use docker-in-docker to run docker builds on my docker jenkins slaves. I'm trying to use https://github.com/tehranian/dind-jenkins-slave which looks good, but I don't see an option on the Jenkins ECS plugin to run the slave as privileged which is necessary for docker-in-docker.


-Brandon Wagner

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/kSBWy3gBQbg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANMVJzks3yceTvUxrFd5cGo8tYwSFh%3D00V%3DzL%2BxJVB2kCmi%3DhQ%40mail.gmail.com.

nicolas de loof

unread,
Jan 22, 2016, 2:49:42 PM1/22/16
to jenkins...@googlegroups.com
privileged flag has been added to development build (https://jenkins.ci.cloudbees.com/job/plugins/job/amazon-ecs-plugin/)
anyway, DinD is probably not a good idea (there's really few docker usages to actually require it). What's your actual need ?

Brandon Wagner

unread,
Jan 22, 2016, 3:01:46 PM1/22/16
to jenkins...@googlegroups.com
I would like to run Docker containers for all of my software projects and dynamically allocate build slaves via ECS (so that I can have a core cluster that can do builds quickly; in contrast to spinning up an EC2 instance).

 For example, I have a Java application which is completely contained in a Docker container (I can build it, run tests, and run the actual application with Tomcat all within the container). I want to use this for a variety of different purposes (dev, testing, qa, and production). In order to make it reusable like that, I don't want to include Jenkins Slave packages and expose ports. I'd rather deploy out a Jenkins-Slave container to my ECS cluster, and then have that slave handle running my application's docker container which also performs tests. 

I also support other team applications which are already running docker container builds in Jenkins (locally on the Jenkins Master). I want it to be transparent to them that I'm "outsourcing" build slaves to ECS. It shouldn't matter to them that I'm changing the way Jenkins is performing builds.

Let me know if you (or anyone else) have suggestions based on my goals.

-Brandon Wagner


nicolas de loof

unread,
Jan 23, 2016, 1:09:02 PM1/23/16
to jenkins...@googlegroups.com
You could use docker-custom-build-environment-plugin for this exact scenario, with bind mounted /var/run/docker.sock so you can run containers side by side (vs "in-docker"). Would need some tests on my side to ensure this scenario is supported, I have this on my TOD for a while but never took time to setup a test environment for it...

Brandon Wagner

unread,
Jan 25, 2016, 10:33:52 AM1/25/16
to jenkins...@googlegroups.com
If I'm understanding correctly, I would mount the docker.sock to the slave container? I created an image extended from the jenkinsci/jnlp-slave that does a wget for the docker CLI. 

However, I don't see a place to mount the docker.sock through the ECS configuration options. 


-Brandon Wagner

nicolas de loof

unread,
Jan 25, 2016, 10:52:30 AM1/25/16
to jenkins...@googlegroups.com
Latest development build for ECS plugin do let you define bind mounts, see https://jenkins.ci.cloudbees.com/job/plugins/job/amazon-ecs-plugin/

Brandon Wagner

unread,
Jan 25, 2016, 2:23:28 PM1/25/16
to jenkins...@googlegroups.com
Ok, I've made progress. I'm able to run a docker container along side the slave container on ECS. However, I just used the amazon-ecs-plugin. When I tried using the CloudBees Docker Custom build Environment Plugin, I kept getting "Cannot start container ........ System error: no such file or directory" 

If I just do a shell script "docker pull java && docker run java java -version" it works.

Is there any advantage in using the CloudBees Docker Custom build Environment Plugin rather than shell scripts? I'm hesitant in using shell scripts since people may see shell commands and start plugging in other commands rather than just using the Docker CLI commands.


-Brandon Wagner

Mulloy Morrow

unread,
Feb 1, 2016, 1:48:15 PM2/1/16
to Jenkins Users


Has anyone successfully been able to mount the Docker UNIX socket on the slave containers? I've attempted to mount this socket using the Jenkins ECS plugin (v1.2) by configuring "container mount points".  (see jenkins config screenshot below)

Mulloy Morrow

unread,
Feb 1, 2016, 5:55:23 PM2/1/16
to Jenkins Users
Was able to get this working. Mounted the docker socket using the mount point configs in the jenkins plugin. However, I was getting a permission denied when trying to nc or curl the socket for info. I had to run the slaves as user root rather than user jenkins. Has either of you come across this issue? 

nicolas de loof

unread,
Feb 2, 2016, 2:41:30 AM2/2/16
to jenkins...@googlegroups.com
docker socket is only accessible to users in docker group or to root. running from a container doesn't bypass such permission check.

Mulloy Morrow

unread,
Feb 2, 2016, 11:04:34 AM2/2/16
to jenkins...@googlegroups.com

My Jenkins user is part of the docker group. That's why I was surprised by this error.



For more options, visit https://groups.google.com/d/optout.
--

Best,
Mulloy Morrow
858.598.3059

Rajasekaran R

unread,
Jan 25, 2017, 6:58:27 AM1/25/17
to Jenkins Users
Yes you are correct I am also running my slave jenkins user under docker group but I cant run docker commands using Jenkins user.

My Dockerfile end of the lines look likes..

RUN usermod -aG docker jenkins
RUN gpasswd -a jenkins docker
#RUN systemctl restart docker
USER jenkins

ENTRYPOINT ["/usr/local/bin/jenkins-slave"]

Kidly suggest how to fix this issue.
Reply all
Reply to author
Forward
0 new messages