본문 바로가기

리눅스

[리눅스] jenkins 도커 컨테이너로 올리기

728x90

jenkins 도커 컨테이너로 올리기

docker-compose.yml 편집

$ git clone https://github.com/anti1346/docker-jenkins.git

$ cd docker-jenkins

$ vim docker-compose.yml
version: '3'
services:

  master:
    image: jenkins/jenkins:lts
    restart: always
    container_name: jenkins
    privileged: true
    #user: root
    #environment:
    volumes:
      - /usr/share/zoneinfo/Asia/Seoul:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - /usr/bin/docker:/usr/bin/docker
      - ./jenkins_home:/var/jenkins_home
    ports:
      - 8080:8080
      - 50000:50000

jenkins_home 퍼미션 설정

$ chown 1000.1000 jenkins_home

docker-compose 기동

$ docker-compose up -d


$ docker-compose ps
 Name                Command               State                        Ports
---------------------------------------------------------------------------------------------------
jenkins   /sbin/tini -- /usr/local/b ...   Up      0.0.0.0:50000->50000/tcp, 0.0.0.0:8080->8080/tcp

관리자 패스워드 확인

$ docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
43cbf881466b49de929277fb677c833a


$ docker-compose logs
jenkins   | *************************************************************
jenkins   | *************************************************************
jenkins   | *************************************************************
jenkins   |
jenkins   | Jenkins initial setup is required. An admin user has been created and a password generated.
jenkins   | Please use the following password to proceed to installation:
jenkins   |
jenkins   | 43cbf881466b49de929277fb677c833a
jenkins   |
jenkins   | This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
jenkins   |
jenkins   | *************************************************************
jenkins   | *************************************************************
jenkins   | *************************************************************

웹 브라우저에서 관리자 패스워드 입력

컨테이너 쉘 접근

###jenkins 계정으로 접근
$ docker exec -it jenkins bash


###root 계정으로 접근
$ docker exec -it --user root jenkins /bin/bash

docker 명령어로 jenkins 시작

docker run -d -v jenkins_home:/var/jenkins_home -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

 

728x90