docker-compose install and configure jenkins

1. Preparation

Create the folder /opt/docker-home/jenkins/jenkins_home and configure the folder permissions.

$ cd `/opt/docker-home/jenkins
$ sudo chown -R 1000 jenkins_home

2. docker-compose.yml

Create the file docker-compose.yml under the /opt/docker-home/jenkins file with the following configuration.

version: "3"
    image: jenkins/jenkins:2.282-alpine
    container_name: jenkins
    restart: always
      TZ: Asia/Shanghai
      - ./jenkins_home:/var/jenkins_home
      - "8080:8080"
      - "50000:50000"

3. Start

$ docker-compose up -d

Check the file /opt/docker-home/jenkins/jenkins_home/secrets/initialAdminPassword after starting, this is the password after initialization, which is needed for jenkins initialization.

4. Plugin Center Modification

After initialization, you can modify the plug-in center as a domestic mirror source to download faster. Go to Configure System Configuration -> Plugin Management -> Advanced -> Upgrade Site in order, modify it to and submit to save.

5. Installing ansible in a container

$ docker exec -it --user root jenkins bash

After entering the container, modify the image source and change the contents of /etc/apk/repositories to the following.



$ apk add ansible

Leave a Reply