Issue mounting docker.sock in ECS
See original GitHub issueHello,
I’m trying to figure out how to mount docker.sock to the ECS Jenkins agent so that I can spawn other containers for specific build steps. I am having trouble getting it to work properly.
My latest attempt:
pipeline {
agent {
ecs {
cloud 'qa-east-agent-cloud'
label 'qa-east-agent'
memory 1024
image 'ninech/jnlp-slave-with-docker'
mountPoints([
[
name: 'docker_socket',
sourcePath:'unix:///var/run/docker.sock',
containerPath:'unix:///var/run/docker.sock',
readOnly: false
]
])
}
}
...
I’m not sure if this is the correct syntax as it’s not documented anywhere, this is my best attempt I could derive from the code (as I am not an experienced Java developer).
I’m noticing in the logs that these override variables may not actually be applied:
2019-12-06 21:30:02.146+0000 [id=1528] INFO c.c.j.p.a.p.ECSDeclarativeAgent#getAsArgs: In getAsArgs. argMap: {assignPublicIp=false, cloud=qa-east-agent-cloud, image=ninech/jnlp-slave-with-docker, label=qa-east-agent, memory=1024, name=qa-east-agent, overrides=[cloud, image, label, memory, mountPoints], privileged=false}
Then below:
2019-12-06 21:30:18.600+0000 [id=1450] INFO c.c.j.p.amazonecs.ECSService#registerTemplate: Created Task Definition: {TaskDefinitionArn: arn:aws:ecs:us-east-1:618804428340:task-definition/qa-east-agent-cloud-qa-east-agent-q9tn0:1,ContainerDefinitions: [{Name: qa-east-agent-cloud-qa-east-agent-q9tn0,Image: ninech/jnlp-slave-with-docker,Cpu: 0,Memory: 1024,Links: [],PortMappings: [],Essential: true,EntryPoint: [],Command: [],Environment: [],MountPoints: [],VolumesFrom: [],Secrets: [],DependsOn: [],Privileged: false,DnsServers: [],DnsSearchDomains: [],ExtraHosts: [],DockerSecurityOptions: [],Ulimits: [],SystemControls: [],ResourceRequirements: [],}],Family: qa-east-agent-cloud-qa-east-agent-q9tn0,Revision: 1,Volumes: [],Status: ACTIVE,RequiresAttributes: [],PlacementConstraints: [],Compatibilities: [EC2],RequiresCompatibilities: [],InferenceAccelerators: [],}
Specifically, MountPoints: []. Confirmed that this is also an empty list in the resulting task definition.
I noticed in this pull request (https://github.com/jenkinsci/amazon-ecs-plugin/pull/13) this use case is specifically referenced in the comments, but I am having trouble finding examples.
Can anyone point me in the right direction?
Thanks.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)

Top Related StackOverflow Question
I don’t have it in CASC, but our config looks like this in the UI and it works fine
I’ve set the mounts as suggested by @webratz, but I’m thinking I have permissions issues on the ec2 host for the docker.sock file - docker can’t see the sock file inside the container. Is there something you’ve done to get the permissions correct? It’s using the Jenkins user in the container, which I suspect is the problem.