question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue mounting docker.sock in ECS

See original GitHub issue

Hello,

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:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
webratzcommented, Jan 31, 2020

I don’t have it in CASC, but our config looks like this in the UI and it works fine Screen Shot 2020-01-31 at 1 04 56 PM

1reaction
GingaNinjacommented, Oct 1, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bind mounts - Amazon Elastic Container Service
With bind mounts, a file or directory on a host, such as an Amazon EC2 instance or AWS Fargate, is mounted into a...
Read more >
docker.sock bind mount AWS ECS Fargate - Stack Overflow
You are trying to access the Docker socket from within a container managed by AWS. I guess this is not available. Instead, you...
Read more >
Docker socket is not allowed to mount inside any containers
The Docker socket docker.sock should not be mounted inside a container. Rationale. If the Docker socket is mounted inside a container it could...
Read more >
Deploying Docker containers on ECS - Docker Documentation
To deploy Docker containers on ECS, you must meet the following requirements: Download and install the latest version of Docker Desktop. Download for...
Read more >
Docker Volume Mounts on ECS does not work as expected
EDIT: The issue got solved. There is no problems with the JSON file, the issue was in my container which was executing. I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found