docker-compose file

时区还有点问题再调 启动:docker-compose -f docker-compose-jenkins.yml -p jenkins up -d

  1. version: '3'
  2. services:
  3. jenkins:
  4. image: jenkins/jenkins:lts # 镜像`jenkins/jenkins:lts`
  5. container_name: jenkins # 容器名为'jenkins'
  6. restart: always # 指定容器退出后的重启策略为始终重启
  7. volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录 (下面映射可在容器中执行宿主机docker命令)
  8. - "/usr/bin/docker:/usr/bin/docker"
  9. - "/var/run/docker.sock:/var/run/docker.sock"
  10. - "/usr/local/java:/usr/local/java" # 挂载物理机的jdk
  11. - "/usr/lib64/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7"
  12. - "./jenkins_home:/var/jenkins_home"
  13. environment: # 设置环境变量,相当于docker run命令中的-e
  14. TZ: Asia/Shanghai
  15. LANG: en_US.UTF-8
  16. JAVA_OPTS: -Duser.timezone=Asia/Shanghai
  17. user: root # 使用root权限运行容器【docker中通过`-u root`命令】
  18. ports: # 映射端口
  19. - "8080:8080"