๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Server/Docker

[Docker] Ubuntu ์—์„œ Docker Compose ์‹คํ–‰ (with Github, VirtualBox)

by soy๋ฏธ๋‹ˆ 2021. 10. 1.



 

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ์œˆ๋„์šฐ ๋กœ์ปฌ์˜ Docker ์—์„œ ๋งŒ๋“ค๊ณ  ๊นƒํ—ˆ๋ธŒ์— ์˜ฌ๋ ค๋†“์€ docker-compose.yml ์„ ubuntu ํ™˜๊ฒฝ์—์„œ ํด๋ก  ๋ฐ›์•„์™€์„œ ์‹คํ–‰ํ•ด๋ณด๋Š” ์‹ค์Šต ๊ณผ์ •์„ ์ ์–ด๋ณด์•˜๋‹ค. ์šฐ๋ถ„ํˆฌ์—์„œ๋Š” ๋„์ปค ์„ค์น˜์™€ ๊นƒ ํด๋ก ํ•˜๋Š” ๊ณผ์ •๋งŒ ์ž˜ ํ•ด๊ฒฐํ•˜๋ฉด docker-compose ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋ฐ ํฐ ์–ด๋ ค์›€์€ ์—†์„ ๊ฒƒ ๊ฐ™๋‹ค.

 

 

 

1. virtual box์—์„œ ์ƒˆ๋กœ์šด ๋„คํŠธ์›Œํฌ ๋งŒ๋“ค๊ธฐ

 

 

 

2. ์šฐ๋ถ„ํˆฌ ์„ค์ •ํ•˜๊ธฐ

 

sudo update
sudo upgrade -y

# ๋„์ปค ํ•„์ˆ˜ ํŒจํ‚ค์ง€ ์„ค์น˜
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

# GPG KEY ์ธ์ฆ
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -


# ๋„์ปค ๋ ˆํŒŒ์ง€ํ† ๋ฆฌ ๋“ฑ๋ก
arch 

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

# ๋„์ปค ์„ค์น˜
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io

# ๋„์ปค ์„ค์น˜ ํ™•์ธ
docker -v

# ์šฐ๋ถ„ํˆฌ ์—ด๋ฉด ๋„์ปค ์‹œ์ž‘ํ•˜๋„๋ก ์„ค์ •
sudo systemctl enable docker && service docker start

# ๋„์ปค ์‹คํ–‰ ์ƒํƒœ
service docker status

# ๋„์ปค ํ—ˆ๋ธŒ ๋กœ๊ทธ์ธ
docker login

 

docker login ํ›„์— Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/auth": dial unix /var/run/docker.sock: connect: permission denied ์—๋Ÿฌ๊ฐ€ ๋œจ๋ฉด

sudo chmod 666 /var/run/docker.sock  ๋ช…๋ น์–ด ์‹คํ–‰ํ•ด์ฃผ๋ฉด Login Succeeded ๋œ๋‹ค.

 

 

 

 

3. docker-compose ํ”„๋กœ์ ํŠธ ํด๋ก ํ•˜๊ธฐ

 

# ๊นƒํ—ˆ๋ธŒ ์„ค์น˜
sudo apt-get install git -y

# ๊นƒ ํด๋ก 
mkdir /opt/app
git clone https://github.com/qwa310/DockerCompose.git /opt/app  # compose ํด๋”

cd ๊นƒํด๋ก  ๋ฐ›์€ ํด๋” 
docker-compose up -d

 

 

 

 

ํด๋ก  ๋ฐ›์€ ํด๋”์— ์žˆ๋Š” docker-compose.yml ์ตœ์ƒ๋‹จ์— version ์„ ๋ช…์‹œํ•ด ๋‘์ง€ ์•Š์œผ๋ฉด invalid ์—๋Ÿฌ๊ฐ€ ๋‚œ๋‹ค. ์ด๊ฒƒ ๋•Œ๋ฌธ์— ์‚ฝ์งˆ์„ ๋ช‡ ์‹œ๊ฐ„ ํ–ˆ๋Š”์ง€.. ๋‹ค๋ฅธ ๋„์ปค ํŒŒ์ผ๋“ค ์ˆ˜์ •ํ•˜๊ณ  ๋‚œ๋ฆฌ์˜€๋Š”๋ฐ ๊ฒฐ๊ตญ ๋ฒ„์ „ ๋ช…์‹œ๊ฐ€ ๊ทผ๋ณธ์ ์ธ ๋ฌธ์ œ์˜€๋‹ค.

 

 

 

 

 

๐Ÿ’ก mobaxterm ํ”„๋กœ์ ํŠธ ํด๋” ๊ฒฝ๋กœ

 

 

 

 

 

๐Ÿ’ก NEWTEST docker-compose.yml ์ •์ƒ ์‹คํ–‰

 

 

 

 

 

๐Ÿ’ก http://๋‚ด IPv4 ์ฃผ์†Œ:8080 ๋กœ ์›น ์‹คํ–‰

 

 

 

 

 

 

 

๐Ÿ’ก DB ํ™•์ธ

 

 

 

 

 

๋Œ“๊ธ€