๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Jenkins

Jenkins ์„ค์น˜ (Docker)

by Soono991 2023. 5. 31.

๐Ÿ’ก ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ๋„์ปค๋ฅผ ์ด์šฉํ•˜์—ฌ ์  ํ‚จ์Šค๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

 

์œˆ๋„์šฐ์— ์  ํ‚จ์Šค๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋ž˜ ํฌ์ŠคํŒ…์— ์ •๋ฆฌํ•ด ๋‘์—ˆ์Šต๋‹ˆ๋‹ค.

 

 

Jenkins ์„ค์น˜ (Window)

๐Ÿ’ก ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ์œˆ๋„์šฐ์— ์  ํ‚จ์Šค๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๋จผ์ € ์  ํ‚จ์Šค๋Š” ์ž๋ฐ”๋กœ ๊ฐœ๋ฐœ๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— JDK๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์šด๋กœ๋“œ ๋งํฌ ๋‹ค์šด๋กœ๋“œํ•œ

soono-991.tistory.com

 

์œˆ๋„์šฐ์— Docker-Desktop์„ ์‚ฌ์šฉํ•˜์—ฌ ์  ํ‚จ์Šค๋ฅผ ์„ค์น˜ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ๋จผ์ € Docker-Desktop์ด ์„ค์น˜๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

๐Ÿ’ก powershell์„ ์‹คํ–‰ํ•˜๊ณ  docker ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์„œ docker๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰์ค‘์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

 

# download jenkins docker image
docker pull jenkins/jenkins

# run jenkins
docker run -d -p 8080:8080 -p 50000:50000 --name jenkins-server --restart=on-failure jenkins/jenkins:lts-jdk11
docker run -d -p 8080:8080 -p 50000:50000 --name jenkins-server --restart=on-failure -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts-jdk11

 

๐Ÿ’ก ์  ํ‚จ์Šค ์ด๋ฏธ์ง€๋ฅผ ๋‚ด๋ ค๋ฐ›์Šต๋‹ˆ๋‹ค.

 

 

๐Ÿ’ก docker๋ฅผ ์ด์šฉํ•ด jenkins๋ฅผ ์„ค์น˜ ๋ฐ ์‹คํ–‰ํ•˜๊ฒŒ ๋˜๋ฉด docker-desktop ์ฝ˜์†”์— jenkins ์ดˆ๊ธฐ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ถœ๋ ฅ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋งŒ์•ฝ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์žŠ์–ด๋ฒ„๋ ธ์„ ๊ฒฝ์šฐ์•„๋ž˜ 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•์„ ํ†ตํ•ด ๋‹ค์‹œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
1. docker logs ๋ช…๋ น์–ด ์‚ฌ์šฉ
2. docker ์ง์ ‘ ์ ‘์†ํ•˜์—ฌ ๋น„๋ฐ€๋ฒˆํ˜ธ ํŒŒ์ผ ํ™•์ธ
/var/jenkins_home/secrets/initialAdminPassword ๊ฒฝ๋กœ์—์„œ ๋‹ค์‹œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋˜๋Š” powershell์—์„œ docker logs ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ™•์ธํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

1. docker logs ๋ช…๋ น์–ด ์‚ฌ์šฉ

# docker ps๋กœ ์‹คํ–‰ ์ค‘์ธ jenkins์˜ container id ํ™•์ธ
docker ps

# docker logs [container id]
docker logs [jenkins container id]

 

 

 

 

2. docker ์ง์ ‘ ์ ‘์†

 

# docker ps๋กœ ์‹คํ–‰ ์ค‘์ธ jenkins์˜ container id ํ™•์ธ
docker ps

# docker exec -it [container id] /bin/bash
docker exec -it [jenkins container id] /bin/bash

 

 

์  ํ‚จ์Šค ํฌํŠธ ๋ฒˆํ˜ธ๋ฅผ 8080์œผ๋กœ ์„ค์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— localhost:8080์œผ๋กœ ์ ‘์†ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ํ™”๋ฉด์ด ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค.

 

 

์•ž์„œ ํ™•์ธํ–ˆ๋˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋˜๋ฉฐ, ์ดํ›„ ๊ณผ์ •์€ ์œˆ๋„์šฐ์—์„œ ์  ํ‚จ์Šค ์„ค์น˜ ๊ณผ์ •๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.

'Jenkins' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Jenkins ์„ค์น˜ (Window)  (0) 2023.05.07

๋Œ“๊ธ€