archery
安装docker-compose
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod 755 /usr/local/bin/docker-compose docker-compose version
yum install epel-release yum-utils yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install docker-ce -y systemctl enable docker --now systemctl start docker systemctl status docker
version: '3' services: # 集合 docker_jenkins: user: root # 为了避免一些权限问题 在这我使用了root restart: always # 重启方式 image: jenkins/jenkins:lts # 指定服务所使用的镜像 在这里我选择了 LTS (长期支持) container_name: jenkins # 容器名称 ports: # 对外暴露的端口定义 - 8082:8080 # 访问Jenkins服务端口 - 50000:50000 volumes: # 卷挂载路径 - /var/vol_dockers/jenkins_home/:/var/jenkins_home # 这是我们一开始创建的目录挂载到容器内的jenkins_home目录 - /var/run/docker.sock:/var/run/docker.sock - /usr/bin/docker:/usr/bin/docker # 这是为了我们可以在容器内使用docker命令 - /usr/local/bin/docker-compose:/usr/local/bin/docker-compose
启动 执行结果如下
[root@localhost docker_compose_jenkins]# docker-compose up -d Creating network "docker_compose_jenkins_default" with the default driver Pulling docker_jenkins (jenkins/jenkins:lts)... lts: Pulling from jenkins/jenkins 1b13d4e1a46e: Pull complete 5303cfd924b5: Pull complete 902fe2af3265: Pull complete 866f59365203: Pull complete da9419a1cff4: Pull complete 0f760cf88b2d: Pull complete e1f034047864: Pull complete b7fd15023031: Pull complete be03ab118c25: Pull complete 13230d8adc6e: Pull complete 52b66e48bb82: Pull complete 7a718fc8b5a4: Pull complete Digest: sha256:a786794ea0a2429e65d67a88fe497cbd97a0d73d73a39f2fd0eae3b380eb70ff Status: Downloaded newer image for jenkins/jenkins:lts Creating jenkins ... done
查看登录密码
docker ps -a 查看容器ID docker logs a52debe35ff1 #容器id获取密码 Jenkins initial setup is required. An admin user has been created and a password generated. Please use the following password to proceed to installation: 54e6428716b742d8ad6a76542f7e9bfb This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
访问: http://jenkinsIP :8082/