๋ณธ ํ๋ก์ ํธ๋ Docker๋ฅผ ํ์ฉํ์ฌ ๊ฐ๋ฐ ์ํฌ์คํ ์ด์ ํ๊ฒฝ์ ๊ตฌ์ถํ๋ ๊ฒ์ ๋ชฉํ๋ก ํ๋ค.
Git๊ณผ GitHub๋ฅผ ์ด์ฉํ ๋ฒ์ ๊ด๋ฆฌ ํ๊ฒฝ์ ๊ตฌ์ฑํ๊ณ ,
Docker๋ฅผ ํตํด ์ปจํ
์ด๋ ๊ธฐ๋ฐ์ ์คํ ํ๊ฒฝ์ ์ง์ ๊ตฌ์ฑ ๋ฐ ์ค์ตํ์๋ค.
์ด๋ฅผ ํตํด ์ด๋ฏธ์ง์ ์ปจํ ์ด๋์ ๊ฐ๋ , ๊ทธ๋ฆฌ๊ณ ๊ฒฉ๋ฆฌ๋ ์คํ ํ๊ฒฝ์ ํน์ง์ ์ดํดํ๊ณ ์ ํ๋ค.
- OS: macOS (MacBook Air)
- ํฐ๋ฏธ๋: macOS ๊ธฐ๋ณธ ํฐ๋ฏธ๋
- Git: Git CLI
- ์๊ฒฉ ์ ์ฅ์: GitHub
- ์ปจํ ์ด๋ ํ๊ฒฝ: OrbStack (Docker Engine)
- Docker ๋ฒ์ : 28.5.2
- [O] ํฐ๋ฏธ๋ ๊ธฐ๋ณธ ์กฐ์ ๋ฐ ํด๋ ๊ตฌ์ฑ
- [O] ๊ถํ ๋ณ๊ฒฝ ์ค์ต
- [O] Docker ์ค์น ๋ฐ ์ ๊ฒ
- [O] hello-world ๋ฐ ubuntu ์คํ
- [O] Dockerfile ๋น๋ ๋ฐ ์คํ
- [O] ํฌํธ ๋งคํ ์ ์
- [O] ๋ฐ์ธ๋ ๋ง์ดํธ ๋ฐ์
- [O] ๋ณผ๋ฅจ ์์์ฑ ๊ฒ์ฆ
- [O] Git ์ค์ ๋ฐ GitHub ์ฐ๋
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % pwd
/Users/sam/Documents/GitHub/codyssey-workstation
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % ls
README.md
# ํ์ฌ ์์น ํ์ธ
sam@yeon-eowamaeche-ui-MacBookAir ~ % pwd
/Users/sam
# ํด๋ ์์ฑ ๋ฐ ์ด๋
sam@yeon-eowamaeche-ui-MacBookAir ~ % mkdir terminal_test
sam@yeon-eowamaeche-ui-MacBookAir ~ % cd terminal_test
# ๋น ํ์ผ ์์ฑ ๋ฐ ๋ชฉ๋ก ํ์ธ (์จ๊น ํ์ผ ํฌํจ)
sam@yeon-eowamaeche-ui-MacBookAir terminal_test % touch empty_file.txt
sam@yeon-eowamaeche-ui-MacBookAir terminal_test % ls -la
total 0
drwxr-xr-x 3 sam staff 96 3 30 21:00 .
drwxr-x---+ 85 sam staff 2720 3 30 21:00 ..
-rw-r--r-- 1 sam staff 0 3 30 21:00 empty_file.txt
# ํ์ผ ๋ด์ฉ ์์ฑ ๋ฐ ํ์ธ
sam@yeon-eowamaeche-ui-MacBookAir terminal_test % echo "Hello Codyssey!" > text_file.txt
sam@yeon-eowamaeche-ui-MacBookAir terminal_test % cat text_file.txt
Hello Codyssey!
# ํ์ผ ๋ณต์ฌ
sam@yeon-eowamaeche-ui-MacBookAir terminal_test % cp text_file.txt copy_file.txt
# ์ด๋/์ด๋ฆ ๋ณ๊ฒฝ
sam@yeon-eowamaeche-ui-MacBookAir terminal_test % mv copy_file.txt rename_file.txt
# ์์ ํด๋๋ก ์ด๋ ํ ์ญ์
sam@yeon-eowamaeche-ui-MacBookAir terminal_test % cd ..
sam@yeon-eowamaeche-ui-MacBookAir ~ % rm -r terminal_test
# ์ค์ต ๋์ ์์ฑ
sam@yeon-eowamaeche-ui-MacBookAir ~ % touch perm_test.txt
sam@yeon-eowamaeche-ui-MacBookAir ~ % mkdir perm_test_dir
# [๋ณ๊ฒฝ ์ ] ๊ถํ ํ์ธ
sam@yeon-eowamaeche-ui-MacBookAir ~ % ls -l perm_test.txt
-rw-r--r-- 1 sam staff 0 3 30 21:05 perm_test.txt
sam@yeon-eowamaeche-ui-MacBookAir ~ % ls -ld perm_test_dir
drwxr-xr-x 2 sam staff 64 3 30 21:05 perm_test_dir
# ๊ถํ ๋ณ๊ฒฝ ์ํ (ํ์ผ: 755, ํด๋: 700)
sam@yeon-eowamaeche-ui-MacBookAir ~ % chmod 755 perm_test.txt
sam@yeon-eowamaeche-ui-MacBookAir ~ % chmod 700 perm_test_dir
# [๋ณ๊ฒฝ ํ] ๊ถํ ๋น๊ต
sam@yeon-eowamaeche-ui-MacBookAir ~ % ls -l perm_test.txt
-rwxr-xr-x 1 sam staff 0 3 30 21:05 perm_test.txt
sam@yeon-eowamaeche-ui-MacBookAir ~ % ls -ld perm_test_dir
drwx------ 2 sam staff 64 3 30 21:05 perm_test_dir
๊ฒฐ๊ณผ ํ์ธ:
perm_test.txt ํ์ผ์ -rw-r--r-- (644)์์ -rwxr-xr-x (755)๋ก ๋ณ๊ฒฝ๋์ด ์์ ์, ๊ทธ๋ฃน, ๊ธฐํ ์ฌ์ฉ์ ๋ชจ๋์๊ฒ ์คํ(x) ๊ถํ์ด ์ถ๊ฐ๋์์ต๋๋ค.
perm_test_dir ๋๋ ํ ๋ฆฌ๋ drwxr-xr-x (755)์์ drwx------ (700)์ผ๋ก ๋ณ๊ฒฝ๋์ด ์์ ์๋ง ์ฝ๊ธฐ/์ฐ๊ธฐ/์คํ์ด ๊ฐ๋ฅํ๊ณ ๋ค๋ฅธ ์ฌ์ฉ์์ ์ ๊ทผ์ด ์๋ฒฝํ ์ฐจ๋จ๋์์์ ํ์ธํ์์ต๋๋ค.
## Git ์ค์ ๋ฐ GitHub ์ฐ๋
### 1. Git ๊ธฐ๋ณธ ์ค์
```bash
$ git config --global user.name "mackerel07"
$ git config --global user.email "b*********70@gmail.com"
$ git config --global init.defaultBranch main
$ git init
$ git remote add origin https://github.com/mackerel07/codyssey-workstation.git
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % git remote -v
origin https://github.com/mackerel07/codyssey-workstation.git (fetch)
origin https://github.com/mackerel07/codyssey-workstation.git (push)
$ touch README.md
$ git add .
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % git status
On branch main
Your branch is based on 'origin/main', but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % git add README.md
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % git commit -m "feat: chore README.md"
[main abe5c36] feat: chore README.md
1 file changed, 1 insertion(+)
**ํธ๋ฌ๋ธ์ํ
**
### 1. GitHub push ์ธ์ฆ ์คํจ
#### 1) ๋ฌธ์
git push ์คํ ์ ์๋์ ๊ฐ์ ์ธ์ฆ ์ค๋ฅ๊ฐ ๋ฐ์ํ์๋ค.
#### 2) ์์ธ ๊ฐ์ค
GitHub์์ ๋ ์ด์ ๋น๋ฐ๋ฒํธ ๊ธฐ๋ฐ ์ธ์ฆ์ ์ง์ํ์ง ์๊ธฐ ๋๋ฌธ์ ๋ฐ์ํ ๋ฌธ์ ๋ผ๊ณ ํ๋จํ์๋ค.
#### 3) ํ์ธ
GitHub ์ ์ฑ
์ ํ์ธํ ๊ฒฐ๊ณผ, HTTPS ๋ฐฉ์์์๋ ๋น๋ฐ๋ฒํธ ๋์ Personal Access Token ๋๋ ์ธ๋ถ ์ธ์ฆ ๋ฐฉ์์ด ํ์ํจ์ ํ์ธํ์๋ค.
#### 4) ํด๊ฒฐ / ๋์
Visual Studio Code์์ GitHub ๊ณ์ ๋ก๊ทธ์ธ์ ์ํํ์ฌ ์ธ์ฆ์ ์๋ฃํ์๋ค.
์ดํ git push ๋ช
๋ น์ด ์ ์์ ์ผ๋ก ์ํ๋์๋ค.
$ git push
Username for 'https://github.com': mackerel07
Password for 'https://mackerel07@github.com':
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % git push
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 10 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (9/9), 707 bytes | 707.00 KiB/s, done.
Total 9 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/mackerel07/codyssey-workstation.git
* [new branch] main -> main
## โ๏ธ Git ์ญํ
- ๋ก์ปฌ์์ ๋ฒ์ ๊ด๋ฆฌ ์ํ
- GitHub๋ฅผ ํตํด ์๊ฒฉ ์ ์ฅ์์ ์ฝ๋ ๊ณต์
### 2.Docker ๊ธฐ๋ณธ ์คํ
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % docker --version
Docker version 28.5.2, build ecc6942
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
##### Docker๊ฐ ์ ์์ ์ผ๋ก ์ค์น๋๊ณ ์ปจํ
์ด๋ ์คํ์ด ์ฑ๊ณต์ ์ผ๋ก ์ด๋ฃจ์ด์ก์์ ํ์ธํ์๋ค.
### 3. Ubuntu ์ปจํ
์ด๋ ์คํ
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
86790fc5660d: Pull complete
Digest: sha256:186072bba1b2f436cbb91ef2567abca677337cfc786c86e107d25b7072feef0c
Status: Downloaded newer image for ubuntu:latest
root@6599e567239e:/# ls
bin boot dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
root@6599e567239e:/# echo hello
hello
#### ์ปจํ
์ด๋ ๋ด๋ถ์์ ๋ช
๋ น์ด๊ฐ ์ ์์ ์ผ๋ก ์คํ๋๋ฉฐ, ํธ์คํธ์ ๋ถ๋ฆฌ๋ ํ๊ฒฝ์์ ํ์ธํ์๋ค.
### 4. Docker ์ํ ํ์ธ
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6599e567239e ubuntu "bash" About a minute ago Up About a minute interesting_meninsky
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6599e567239e ubuntu "bash" About a minute ago Up About a minute interesting_meninsky
ec0b5630d21c hello-world "/hello" 2 minutes ago Exited (0) 2 minutes ago thirsty_pike
fdc88053091b hello-world "/hello" 12 minutes ago Exited (0) 12 minutes ago goofy_moore
fd30b82f5713 hello-world "/hello" 12 minutes ago Exited (0) 12 minutes ago stoic_brattain
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest eb84fdc6f2a3 6 days ago 5.2kB
ubuntu latest e3847ac055b4 4 weeks ago 101MB
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % docker info
Client:
Version: 28.5.2
Context: orbstack
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.29.1
Path: /Users/sam/.docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.40.3
Path: /Users/sam/.docker/cli-plugins/docker-compose
...์ดํ ์๋ต
sam@yeon-eowamaeche-ui-MacBookAir web % docker stats
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
5d886db78b60 my-web-container 0.00% 7.48MiB / 7.807GiB 0.09% 2.81kB / 1.18kB 10.2MB / 8.19kB 11
sam@yeon-eowamaeche-ui-MacBookAir web % docker logs 5d886db78b60
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
์ดํ์๋ต...
#### ์คํ ์ค์ธ ์ปจํ
์ด๋์ ์ข
๋ฃ๋ ์ปจํ
์ด๋ ์ํ๋ฅผ ํ์ธํ์๋ค.
### exec vs attach ์ฐจ์ด ์ ๋ฆฌ
sam@yeon-eowamaeche-ui-MacBookAir web % docker exec 5d886db78b60 ls
bin
dev
docker-entrypoint.d
docker-entrypoint.sh
์ดํ ์๋ต...
sam@yeon-eowamaeche-ui-MacBookAir web % docker attach 5d886db78b
>๋๋ค ์ปจํ
์ด๋์ ์ ์ํ๋ ๋ช
๋ น์ด์ง๋ง, attach๋ ์ปจํ
์ด๋์ ์ง์ ์ฐ๊ฒฐํ์ฌ ์ ์ดํ๊ณ , exec๋ ์ปจํ
์ด๋ ๋ด๋ถ์ ์๋ก์ด ํ๋ก์ธ์๋ฅผ ์คํํ์ฌ ์ ์ํ๋ค
### ๋ฐ์ธ๋ ๋ง์ดํธ ์ ํ ๋ณ๊ฒฝ
#### ํธ์คํธ์์ ํ์ธ
sam@yeon-eowamaeche-ui-MacBookAir ~ % mkdir bind-test
sam@yeon-eowamaeche-ui-MacBookAir ~ % cd bind-test
sam@yeon-eowamaeche-ui-MacBookAir bind-test % echo "hello" > test.txt
sam@yeon-eowamaeche-ui-MacBookAir bind-test % cat test.txt
hello
#### ์ปจํ
์ด๋์์ ํ์ธ
sam@yeon-eowamaeche-ui-MacBookAir web % docker run -v $(pwd):/app -it ubuntu
<$(pwd) : ํ์ฌ ๋ด ์ปดํจํฐ ํด๋
/app : ์ปจํ
์ด๋ ๋ด๋ถ ๊ฒฝ๋ก
์ฆ โ ๋ด ํด๋ = ์ปจํ
์ด๋ /app๊ณผ ์ฐ๊ฒฐ๋จ>
root@28c86dae2666:/# cat /app/test.txt
hello
#### ์ปจํ
์ด๋ ์ข
๋ฃ ํ ํธ์คํธ์์ ํ์ผ ์์
root@28c86dae2666:/# exit
exit
sam@yeon-eowamaeche-ui-MacBookAir bind-test % echo "changed" > test.txt
sam@yeon-eowamaeche-ui-MacBookAir bind-test % cat test.txt
changed
#### ์ปจํ
์ด๋ ์ ์ ํ ํ์ธ
sam@yeon-eowamaeche-ui-MacBookAir bind-test % docker run -it -v $(pwd):/app ubuntu bash
root@28c86dae2666::/# cat /app/test.txt
changed
<๋ฐ์ธ๋ ๋ง์ดํธ๋ฅผ ์ฌ์ฉํ์ฌ ํธ์คํธ ๋๋ ํ ๋ฆฌ๋ฅผ ์ปจํ
์ด๋์ ์ฐ๊ฒฐํ์๋ค.
ํธ์คํธ์์ ํ์ผ ๋ด์ฉ์ ๋ณ๊ฒฝํ ํ ์ปจํ
์ด๋์์ ํ์ธํ ๊ฒฐ๊ณผ, ๋ณ๊ฒฝ ์ฌํญ์ด ์ฆ์ ๋ฐ์๋๋ ๊ฒ์ ํ์ธํ์๋ค.
์ด๋ฅผ ํตํด ๋ฐ์ธ๋ ๋ง์ดํธ๋ ํธ์คํธ์ ์ปจํ
์ด๋ ๊ฐ์ ๋์ผํ ํ์ผ ์์คํ
์ ๊ณต์ ํจ์ ์ ์ ์๋ค.>
## **ํธ๋ฌ๋ธ์ํ
**: ๋ฐ์ธ๋ ๋ง์ดํธ ๊ฒฝ๋ก ์ค๋ฅ
๋ฌธ์
๋ฐ์ธ๋ ๋ง์ดํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ปจํ
์ด๋๋ฅผ ์คํํ์ผ๋,
์ปจํ
์ด๋ ๋ด๋ถ `/app` ๋๋ ํ ๋ฆฌ์ ํ์ผ์ด ๋ณด์ด์ง ์๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์๋ค.
์์ธ/๊ฐ์ค
* ํธ์คํธ ๊ฒฝ๋ก๊ฐ ์๋ชป ์ง์ ๋์์ ๊ฐ๋ฅ์ฑ
* ์กด์ฌํ์ง ์๋ ๋๋ ํ ๋ฆฌ๋ฅผ ๋ง์ดํธํ์ ๊ฐ๋ฅ์ฑ
ํ์ธ ๊ณผ์
```bash
docker run -it -v /bind-test:/app ubuntu bash
root@28c86dae2666:/# ls /app
๊ฒฐ๊ณผ:
(์ถ๋ ฅ ์์)
โ `/app` ๋๋ ํ ๋ฆฌ๊ฐ ๋น์ด์๋ ๊ฒ์ ํ์ธ
ํด๊ฒฐ ๋ฐฉ๋ฒ
ํธ์คํธ์ ์ค์ ๊ฒฝ๋ก๋ฅผ ์ ํํ ์ง์ ํ๋๋ก ์์
```bash
docker run -it -v $(pwd):/app ubuntu bash
<๋ฐ์ธ๋ ๋ง์ดํธ ์ฌ์ฉ ์ ํธ์คํธ ๊ฒฝ๋ก๊ฐ ์ ํํ์ง ์์ผ๋ฉด ํ์ผ์ด ๋ณด์ด์ง ์๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค.
`$(pwd)`๋ฅผ ์ฌ์ฉํ์ฌ ํ์ฌ ๋๋ ํ ๋ฆฌ๋ฅผ ์ง์ ํจ์ผ๋ก์จ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์๋ค.>
### Docker ๊ฐ๋
์ ๋ฆฌ
- Docker Image๋ ์ปจํ
์ด๋ ์คํ์ ์ํ ์ค๊ณ๋์ด๋ค.
- Container๋ ์ด๋ฏธ์ง๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์คํ๋ ๋
๋ฆฝ์ ์ธ ํ๊ฒฝ์ด๋ค.
- ์ปจํ
์ด๋ ๋ด๋ถ๋ ํธ์คํธ ์์คํ
๊ณผ ๊ฒฉ๋ฆฌ๋์ด ์๋ค.
### 5.Dockerfile ๊ธฐ๋ฐ ์น ์๋ฒ ์คํ
```bash
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % mkdir web
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % ls
README.md web
sam@yeon-eowamaeche-ui-MacBookAir codyssey-workstation % cd web
sam@yeon-eowamaeche-ui-MacBookAir web % mkdir site
sam@yeon-eowamaeche-ui-MacBookAir web % touch site/index.html
sam@yeon-eowamaeche-ui-MacBookAir web % touch Dockerfile
sam@yeon-eowamaeche-ui-MacBookAir web % nano
sam@yeon-eowamaeche-ui-MacBookAir web % nano site/index.html
####์ฌ์ดํธ ์ฝ๋ ์์ฑ
<h1>Hello Docker</h1>
sam@yeon-eowamaeche-ui-MacBookAir web % ls
Dockerfile site
sam@yeon-eowamaeche-ui-MacBookAir web % ls
Dockerfile site
sam@yeon-eowamaeche-ui-MacBookAir web % nano Dockerfile
sam@yeon-eowamaeche-ui-MacBookAir web % docker build -t my-web:1.0 .
[+] Building 8.9s (7/7) FINISHED docker:orbstack
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 90B
...์ดํ ์๋ต
sam@yeon-eowamaeche-ui-MacBookAir web % docker run -d -p 8080:80 --name my-web-container my-web:1.0
d886db78b607e9cad9ce88bb089600b0114b51f9f6ffa13010a6a413d897445
### ์น์ฌ์ดํธ ์ ์
๋ธ๋ผ์ฐ์ ์ http://localhost:8080 ์ ์ ํ, Hello Docker์ ํ์ธํจ
>์น ์๋ฒ๊ฐ ์ ์์ ์ผ๋ก ์คํ๋๊ณ ํฌํธ ๋งคํ์ด ์ด๋ฃจ์ด์ก์์ ํ์ธํ์๋ค
###์ ์ ๊ฒฐ๊ณผ
๊ธฐ์กด Dockerfile ๊ธฐ๋ฐ ์ปค์คํ
์ด๋ฏธ์ง ์ ์
๋ณธ ์์
์ ์ ์๋ ๋ฐฉ์ ์ค (A) ์น ์๋ฒ ๋ฒ ์ด์ค ์ด๋ฏธ์ง ํ์ฉ + ์ ์ ์ฝํ
์ธ ๊ต์ฒด ๋ฐฉ์์ ์ ํํ์ฌ ์งํํ์๋ค
1) ์ ํํ ๊ธฐ์กด ๋ฒ ์ด์ค ์ด๋ฏธ์ง ๋ฐ Dockerfile ๊ตฌ์ฑ
๋ฒ ์ด์ค ์ด๋ฏธ์ง: nginx:latest (์น ์๋ฒ ๋ฒ ์ด์ค ์ด๋ฏธ์ง)
์ ํ ์ด์ : ๋ณ๋์ ์น ์๋ฒ ์ค์ ์์ด NGINX ๋ฒ ์ด์ค ์ด๋ฏธ์ง์ ๊ธฐ๋ณธ ์น ๋ฃจํธ ๋๋ ํ ๋ฆฌ์ ์ปค์คํ
HTML ํ์ผ๋ง ๋ฎ์ด์ฐ๋ ๋ฐฉ์์ผ๋ก ๋น ๋ฅด๊ณ ๊ฐํธํ๊ฒ ์ ์ ์น์ฌ์ดํธ๋ฅผ ๋ฐฐํฌํ ์ ์๊ธฐ ๋๋ฌธ์.
2) ์ ์ฉํ ์ปค์คํ
ํฌ์ธํธ ๋ฐ ๊ฐ๊ฐ์ ๋ชฉ์
์ปค์คํ
ํฌ์ธํธ 1: site/index.html ํ์ผ ์์ฑ
๋ชฉ์ : NGINX ๊ธฐ๋ณธ ์ฐ์ปด ํ์ด์ง ๋์ , "Hello Docker"๋ผ๋ ๋ฌธ๊ตฌ๊ฐ ์ถ๋ ฅ๋๋ ๋๋ง์ ์ปค์คํ
์ ์ ์น ํ๋ฉด์ ์ ๊ณตํ๊ธฐ ์ํจ.
์ปค์คํ
ํฌ์ธํธ 2: Dockerfile ๋ด COPY ๋ช
๋ น์ด ์ฌ์ฉ
๋ชฉ์ : ํธ์คํธ์์ ์์ฑํ ์ปค์คํ
index.html ํ์ผ์ ์ปจํ
์ด๋ ์ด๋ฏธ์ง ๋ด๋ถ์ NGINX ๊ธฐ๋ณธ ์น ์๋น์ค ๋๋ ํ ๋ฆฌ(/usr/share/nginx/html/)๋ก ๋ณต์ฌํ์ฌ ๊ธฐ์กด ํ์ผ์ ๊ต์ฒดํ๊ธฐ ์ํจ
### 6.๋ณผ๋ฅจ ์์์ฑ ๊ฒ์ฆ
#### ๋ณผ๋ฅจ ์์ฑํ๊ธฐ
sam@yeon-eowamaeche-ui-MacBookAir web % docker volume create mydata
mydata
#### ์ปจํ
์ด๋ ์คํ ๋ฐ ๋ณผ๋ฅจ ์ฐ๊ฒฐ
am@yeon-eowamaeche-ui-MacBookAir web % docker run -d --name vol-test1 -v mydata:/data ubuntu sleep infinity
ea1adb6f419ba06cb28652bb185617c472ffc7762d571e058fff0688a5d7404c
sam@yeon-eowamaeche-ui-MacBookAir web % docker exec -it vol-test1 bash -c "echo 'Volume Data Safe!' > /data/hello.txt && cat /data/hello.txt"
Volume Data Safe!
(๋ด๋ถ์ ์ ์ํด์ hello.txt์ ๊ธ์์ฐ๊ธฐ ๋ฐ ํ์ธ {>์ ํตํด ํ์ผ์์ฑ})
#### ์ปจํ
์ด๋ ์ญ์
sam@yeon-eowamaeche-ui-MacBookAir web % docker rm -f vol-test1
vol-test1
#### ๋ ๋ฒ์งธ ์ปจํ
์ด๋ ์คํ
sam@yeon-eowamaeche-ui-MacBookAir web % docker run -d --name vol-test2 -v mydata:/data ubuntu sleep infinity
ad90c8ff11601ae9454f60f32ed71088991358549a915b0eb6712fc2c9b714ab
#### ๋ฐ์ดํฐ ํ์ธ(์์์ฑ ๊ฒ์ฆ)
sam@yeon-eowamaeche-ui-MacBookAir web % docker exec -it vol-test2 bash -c "cat /data/hello.txt"
Volume Data Safe!
<์ ๊ณผ์ ์ ํตํด ์ฒซ ๋ฒ์งธ ์ปจํ
์ด๋(vol-test1) ๋ด๋ถ์ ์์ฑํ ๋ฐ์ดํฐ๊ฐ ์ปจํ
์ด๋ ๊ฐ์ ์ญ์ ํ์๋ ์ ์ค๋์ง ์์์ ์ง์ ํ์ธํ์๋ค.
์์ ํ ์๋ก์ด ๋ ๋ฒ์งธ ์ปจํ
์ด๋(vol-test2)๋ฅผ ์คํํ์ฌ ๋์ผํ ๋ณผ๋ฅจ(mydata)์ ๋ง์ดํธํ์ ๋, ์ด์ ์ปจํ
์ด๋์์ ์์ฑํ๋ ๋ฐ์ดํฐ(hello.txt)๋ฅผ ๊ทธ๋๋ก ์กฐํํ ์ ์์๋ค.
์ด๋ฅผ ํตํด ์ปจํ
์ด๋์ ์๋ช
์ฃผ๊ธฐ(์์ฑ/์ญ์ )์๋ ๋
๋ฆฝ์ ์ผ๋ก ํธ์คํธ์ ๋ฐ์ดํฐ๋ฅผ ์์ ํ๊ฒ ๋ณด์กดํ๋ Docker ๋ณผ๋ฅจ์ ์์์ฑ(Persistence) ํน์ง์ ์ฑ๊ณต์ ์ผ๋ก ๊ฒ์ฆํ์๋ค.>
### 7.Git ์ค์ ๋ฐ Github ์ฐ๋ ์ฆ๊ฑฐ
sam@yeon-eowamaeche-ui-MacBookAir web % git config --list
credential.helper=osxkeychain
init.defaultbranch=main
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
user.name=mackerel07
user.email=b*********170@gmail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
submodule.active=.
remote.origin.url=https://github.com/mackerel07/codyssey-workstation.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
lfs.repositoryformatversion=0
### 8.๋ณด์ ๋ฐ ๊ฐ์ธ์ ๋ณด ๋ณดํธ ์ค์
๋ณธ ๊ธฐ์ ๋ฌธ์(README.md) ๋ฐ ์ฒจ๋ถ๋ ๋ชจ๋ ํฐ๋ฏธ๋ ๋ก๊ทธ, ์คํฌ๋ฆฐ์ท ์์ฑ ์ ์๋์ ๋ณด์ ์์น์ ์ฒ ์ ํ ์ค์ํ์์ต๋๋ค.
ํฐ๋ฏธ๋ ์กฐ์ ๋ก๊ทธ ๊ธฐ๋ก ์ค ๋ฐ์ํ ์ ์๋ ๊ฐ์ธ ํ ํฐ(PAT), ๋น๋ฐ๋ฒํธ, ์ธ์ฆ ์ฝ๋ ๋ฑ์ ๋ฏผ๊ฐ ์ ๋ณด๋ ๋ฌธ์์ ํฌํจํ์ง ์์์ต๋๋ค.
GitHub Push ๊ณผ์ ์์ ๋ฐ์ํ ์ธ์ฆ ๋จ๊ณ ๊ธฐ๋ก ์, ๋ฏผ๊ฐํ ์๊ฒฉ ์ฆ๋ช
์ ๋ณด๊ฐ ํ
์คํธ๋ ์ด๋ฏธ์ง๋ก ๋
ธ์ถ๋์ง ์๋๋ก ์ฃผ์ํ์์ผ๋ฉฐ, ์์ ํ VSCode OAuth ์ฐ๋ ๋ฐฉ์์ ์ฑํํ์ฌ ๊ฐ์ธ์ ๋ณด๋ฅผ ๋ณดํธํ์์ต๋๋ค.
๊ฒฐ๊ณผ์ ๋์ค๋ ๋ณธ์ธ์ ์ค์ ์ด๋ฉ์ผ์ ๊ฐ์ธ์ ๋ณด์ ํด๋นํ์ฌ ๋ง์คํน ์ฒ๋ฆฌ ํ์์ต๋๋ค.
๊ธฐํ๋งํฌ:
์น์ฌ์ดํธ ํฌํธ๋งคํ ๊ฒ์ฆ: https://ibb.co/bjwHrRJP
๊นํ๋ธ ์ฐ๋๊ฒ์ฆ(git push): https://ibb.co/bjwHrRJP
๊นํ๋ธ ์ฐ๋(๋ก๊ทธ์ธ): https://ibb.co/yFptmj1s