Skip to content

SwanAudio/jenkins-docker-swarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Swan Audio

A docker file for deploying jenkins swarm plugin agents, that have docker installed, to a docker swarm.

Usage

Due to docker-swarm not supporting broadcast in overlay networking, the name jenkins-master must be used for the master server.

Example compose file (should probably use nginx proxy to port 80 and better secret management for real usage):

version: '3.5'
services:
  jenkins-master:
    image: jenkins/jenkins:lts
    volumes:
      - jenkins-data:/var/jenkins_home
    ports:
      - 50000:50000
      - target: 8080
        published: 8080
        protocol: tcp
        mode: host
    networks:
      - jenkins-network
      - bridge
  jenkins-agent:
    image: swanaudio/jenkins-swarm-slave
    networks:
      - jenkins-network
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    secrets:
      - jenkins-password
      - jenkins-username

networks:
  bridge:
    external: true
    name: bridge
  jenkins-network:
    driver: overlay
    attachable: true

volumes:
  jenkins-data:

secrets:
  jenkins-password:
    file: jenkinspw
  jenkins-username:
    file: jenkinsuser

Gotchas

The mounted docker.sock must have matching group ID in the container as in the image.

The easiest (altho not super elegant) way to get around this is to add something similar to the following in your yml file.

jenkins-agent:
    user: jenkins:${DOCKER_GID}

and than execute the following:

DOCKER_GID=`stat -c /var/run/docker.sock` docker stack deploy -c /path/to/stack.yml jenkins

About

A docker file for deploying jenkins swarm plugin agents, that have docker installed, to a docker swarm.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors