๐Ÿ”ฅ์ฑŒ๋ฆฐ์ง€1์ฃผ์ฐจ - Docker { $(pwd) }

hyunwooยท2023๋…„ 3์›” 25์ผ
0

UMC 4๊ธฐ

๋ชฉ๋ก ๋ณด๊ธฐ
4/6
post-custom-banner

์ถœ์ฒ˜: https://michaelbrooks.co.uk/windows-version-of-linuxs-pwd/

http-server๊ฐ€ ๊น”๋ ค ์žˆ๋Š” frontent-img๋ฅผ ์ปจํ…Œ์ด๋„ˆ๋กœ run ์‹คํ–‰์„ ์‹œํ‚ฌ ๋•Œ ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค.

$(pwd) ์— ๋Œ€ํ•ด์„œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ

docker run --name frontend-con -v $(pwd):/home/node/app -p 8080:8080 front e 
nt-img
// 
-v ์˜ต์…˜ : volume์˜ ์•ฝ์ž๋กœ ๋„์ปค์—์„œ ๋ณผ๋ฅจ์ด๋ž€, ์ปจํ…Œ์ด๋„ˆ์™€ ํŠน์ • ํด๋”๋ฅผ ๊ณต์œ ํ•˜๋Š” ๊ฑธ ๋งํ•œ๋‹ค.
pwd ๋ช…๋ ์–ด :ํ˜„ ์œ„์น˜๋ฅผ ์ถœ๋ ฅ
-p ์˜ต์…˜ : ํฌํŠธ 

์œ„์˜ ์ฝ”๋“œ๋กœ ์‹คํ–‰์„ ํ•˜๋ฉด

docker: Error response from daemon: create $(pwd): "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.

์ด์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋‚˜์™€์„œ ์ฐพ์•„๋ณธ ๊ฒฐ๊ณผ

$(pwd) ๋ฅผ %cd% ๋กœ ๋ฐ”๊พธ๋ฉด ๋œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค.

docker run --name frontend-con -v %cd%:/home/node/app -p 8080:8080 frontent-img

C:\Users\_____\docker_practice\practice-docker\frontend>docker run --name frontend-con -v %cd%:/home/node/app -p 8080:8080 frontent-img
Starting up http-server, serving ./public

http-server version: 14.1.1

http-server settings:
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://127.0.0.1:8080
  http://172.17.0.2:8080
Hit CTRL-C to stop the server

์ด๋ ‡๊ฒŒ ์ •์ƒ์ ์œผ๋กœ 8080์œผ๋กœ ์„œ๋ฒ„๊ฐ€ ์—ด๋ฆฌ๊ฒŒ ๋œ๋‹ค.

โญ๏ธ ๋ชจ๋“  ์ปจํ…Œ์ด๋„ˆ์™€ ์ด๋ฏธ์ง€ ๋“ฑ ๋„์ปค ์š”์†Œ ์ค‘์ง€ ๋ฐ ์‚ญ์ œ

cmd์—์„œ ์ด ์ฝ”๋“œ๊ฐ€ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด Windows PowerShell์—์„œ ํ•˜๋ฉด ๋œ๋‹ค.

# ๋ชจ๋“  ์ปจํ…Œ์ด๋„ˆ ์ค‘์ง€
docker stop $(docker ps -aq)

# ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” ๋ชจ๋“  ๋„์ปค ์š”์†Œ(์ปจํ…Œ์ด๋„ˆ, ์ด๋ฏธ์ง€, ๋„คํŠธ์›Œํฌ, ๋ณผ๋ฅจ ๋“ฑ) ์‚ญ์ œ
docker system prune -a

CMD (์ž‘๋™ํ•˜์ง€ ์•Š๋Š”๋‹ค.)

C:\Users\____\docker_practice>docker stop $(docker ps -aq)
unknown shorthand flag: 'a' in -aq)
See 'docker stop --help'.

PowerShell (์ •์ƒ์ ์ธ ๋ชจ๋“  ์ปจํ…Œ์ด๋„ˆ ์ค‘์ง€)

PS C:\Users\_____\docker_practice> docker stop $(docker ps -aq)
2f6a6539ac7f
e17b4d686483
PS C:\Users\_____\docker_practice> 
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€