โš™๏ธ Devops/๐Ÿณ Docker

โš™๏ธ Devops/๐Ÿณ Docker

Docker Permission Denied ํ•ด๊ฒฐ๋ฐฉ๋ฒ•

๋„์ปค ๊ถŒํ•œ ๋ฌธ์ œ ์ผ๋ฐ˜ ์œ ์ €๊ฐ€ ๋„์ปค ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ๋งˆ๋‹ค Permission Denied๊ฐ€ ๋– ์„œ sudo๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•˜๋Š” ๋ถˆํŽธํ•จ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋•Œ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์€ ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ œ๊ฐ€ ์•Œ์•„๋ณธ 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํ˜„์žฌ ์‚ฌ์šฉ์ž๋ฅผ ๊ทธ๋ฃน์— ์ถ”๊ฐ€ ํ˜„์žฌ ๋กœ๊ทธ์ธ ๋œ ์œ ์ €๋ฅผ docker ๊ทธ๋ฃน์— ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์œผ๋กœ sudo ๊ถŒํ•œ ์—†์ด ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. sudo usermod -aG docker $USER logout # ๋กœ๊ทธ์•„์›ƒ ํ›„ ๋‹ค์‹œ ๋กœ๊ทธ์ธ ํ›„ ์ ์šฉ ํ•˜์ง€๋งŒ ์œ„ ๋ฐฉ๋ฒ•์€ ์จ๋“œํŒŒํ‹ฐ(jenkins ๋“ฑ) ์œ ์ €์— ๋Œ€ํ•ด์„œ๋Š” ์ ์šฉ์ด ์–ด๋ ค์› ์Šต๋‹ˆ๋‹ค. docker.sock Docker CLI(๋„์ปค ์ปค๋งจ๋“œ๋“ค)๋Š” ๊ฒฐ๊ตญ docker.sock์„ ํ†ตํ•ด์„œ ๋ช…๋ น์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ docker.sock์˜ ๊ถŒํ•œ์„ ์ˆ˜์ •ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค...

โš™๏ธ Devops/๐Ÿณ Docker

๋„์ปค ์ด๋ฏธ์ง€ ๋นŒ๋“œ์‹œ ํ”Œ๋žซํผ ๋ณ€๊ฒฝํ•˜๊ธฐ (feat. M1 Mac)

M1 ๋งฅ์„ ์‚ฌ์šฉ์ค‘์ธ๋ฐ ๋ฌธ์ œ๋Š” M1์ด arm ๊ธฐ๋ฐ˜ ์นฉ์…‹์ด๋ผ ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ๋งŒ๋“ค๋ฉด, arm ํ”Œ๋žซํผ ์ „์šฉ ์ด๋ฏธ์ง€๋กœ ์ƒ์„ฑ์ด ๋ฉ๋‹ˆ๋‹ค. ๊ทผ๋ฐ ์ด๋ฏธ์ง€๋ฅผ ๋ฐฐํฌํ•  ํ™˜๊ฒฝ์€ Ubuntu ์ด๋ฏ€๋กœ ํ•ด๋‹น ์ด๋ฏธ์ง€๊ฐ€ ์ œ๋Œ€๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ ์„ฑ๋Šฅ์ด ์ €ํ•˜๋  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๊ฒฝ๊ณ ์ฐฝ์„ ๋„์›๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ด๋ฏธ์ง€ ๋นŒ๋“œ ์‹œ ์•„๋ž˜ ํ”Œ๋žซํผ ์˜ต์…˜์„ ๋ถ™์—ฌ์„œ ๋นŒ๋“œ๋ฅผ ํ•ด์ฃผ๋ฉด ํ•ด๊ฒฐ์ด ๋ฉ๋‹ˆ๋‹ค. $ docker build --platform amd64 -t [์ด๋ฏธ์ง€๋ช…] . ๋‹ค๋ฅธ ํ”Œ๋žซํผ์œผ๋กœ ๋นŒ๋“œํ•˜๊ณ  ์‹ถ์„ ๋•Œ ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ๋งŒ๋“ค ๋•Œ, ๋ณดํ†ต alpine ์ฒ˜๋Ÿผ ๊ฐ€๋ฒผ์šด ์ด๋ฏธ์ง€๋ฅผ Base ์ด๋ฏธ์ง€๋กœ ์‚ฌ์šฉํ•˜๊ณค ํ•ฉ๋‹ˆ๋‹ค. ๋นŒ๋“œํ•  ๋•Œ ์ง€์›๋˜๋Š” Arch๋„ Base ์ด๋ฏธ์ง€๋ฅผ ๋”ฐ๋ผ๊ฐ€๊ฒŒ ๋˜๋Š”๋ฐ์š”. openjdk ๊ณต์‹ ์ด๋ฏธ์ง€๋ฅผ ์˜ˆ๋กœ ๋“ค๋ฉด, ์—ฌ๋Ÿฌ OS Arch๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ๋ถ„์ด ์ด๋ฏธ์ง€๋ฅผ ์ƒ..

โš™๏ธ Devops/๐Ÿณ Docker

[Docker] Spring boot ํ”„๋กœ์ ํŠธ๋ฅผ ๋„์ปค ์ด๋ฏธ์ง€ํ™” ํ•ด๋ณด๊ธฐ

Spring boot ํ”„๋กœ์ ํŠธ๋ฅผ docker image๋กœ ๋งŒ๋“ค์–ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ฐ„๋‹จํ•œ spring boot ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ HomeController import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HomeController { @GetMapping("/hello") public String hello(@Value("${test.customName}") String name) { ret..

โš™๏ธ Devops/๐Ÿณ Docker

[Docker] MySQL ์„ค์น˜ํ•˜๊ธฐ

docker-compose ๋‹ค์šด๋กœ๋“œ ์•„๋ž˜์—์„œ ์ตœ์‹  ๋ฒ„์ „ ํ™•์ธ! Releases · docker/compose sudo curl -L https://github.com/docker/compose/releases/download/v2.4.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose ๊ถŒํ•œ ์„ค์ • sudo chmod +x /usr/local/bin/docker-compose ์„ค์น˜ ํ™•์ธ docker-compose --version Docker, Docker-Compose ์„ค์น˜ํ•˜๊ธฐ - Ubuntu 20.04 LTS Docker ์„ค์น˜ ์‹คํ–‰ํ™˜๊ฒฝ: Ubuntu 20.04 LTS ์—…๋ฐ์ดํŠธ ๋ฐ HTTP ํŒจํ‚ค์ง€ ์„ค์น˜ $ sudo apt upda..

โš™๏ธ Devops/๐Ÿณ Docker

Docker, Docker-Compose ์„ค์น˜ํ•˜๊ธฐ - Ubuntu 20.04 LTS

Docker ์„ค์น˜ ์‹คํ–‰ํ™˜๊ฒฝ: Ubuntu 20.04 LTS ์—…๋ฐ์ดํŠธ ๋ฐ HTTP ํŒจํ‚ค์ง€ ์„ค์น˜ $ sudo apt update $ sudo apt-get install -y ca-certificates \ curl \ software-properties-common \ apt-transport-https \ gnupg \ lsb-release GPG ํ‚ค ๋ฐ ์ €์žฅ์†Œ ์ถ”๊ฐ€ $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg Repository ๋“ฑ๋ก echo \ "deb [arch=amd64 signed-by=/usr/share/key..

โš™๏ธ Devops/๐Ÿณ Docker

[Docker] Dockerfile ๋ช…๋ น์–ด ์ •๋ฆฌ

Dockerfile์ด๋ž€ Docker ์ด๋ฏธ์ง€๊ฐ€ ์–ด๋–ค ๋‹จ๊ณ„๋ฅผ ๊ฑฐ์ณ ๋นŒ๋“œ(build)๊ฐ€ ๋˜๋Š” ๊ณผ์ •์„ ํ…์ŠคํŠธ ํŒŒ์ผ๋กœ ํ‘œํ˜„ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. Docker ์ด๋ฏธ์ง€์—๋Š” Layer)๊ฐ€ ์žˆ๋Š”๋ฐ ์ด ๋ช…๋ น์–ด ๋ผ์ธ ํ•˜๋‚˜ ํ•˜๋‚˜๊ฐ€ ์‹คํ–‰๋˜๋ฉด์„œ image Layer๋ฅผ ์ด๋ค„์„œ ๊ฒฐ๊ตญ์—๋Š” ํ•˜๋‚˜์˜ ์ด๋ฏธ์ง€๊ฐ€ ๋˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. (*์ถ”ํ›„ ํฌ์ŠคํŒ… ์˜ˆ์ •) *Dockerfile์€ ํ•ญ์ƒ ์ตœ์ƒ์œ„ ๋””๋ ‰ํ† ๋ฆฌ์— ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Dockerfile ๋ช…๋ น๋ฌธ ํ˜•์‹ Key Value # ์ฃผ์„์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ช…๋ น์–ด(INSTRUCTION) ์ธ์ž(arguments) ๋ช…๋ น๋ฌธ์€ ๋ช…๋ น์–ด๋กœ ์‹œ์ž‘ํ•˜๊ณ  ๊ทธ ๋’ค์—๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ธ์ž๋ฅผ ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ช…๋ น์–ด๋Š” ๋Œ€๋ฌธ์ž, ์ธ์ž๋Š” ์†Œ๋ฌธ์ž๋กœ ๊ตฌ๋ถ„์ง€์–ด ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๊ด€๋ก€๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. FROM : # tag ์ƒ๋žต ์‹œ default = late..

iseunghan
'โš™๏ธ Devops/๐Ÿณ Docker' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก