Skip to main content

07L. USER

Less than 1 minuteDevOpsDockercrashcoursepyrasis.comdockerdevops

07L. USER ๊ด€๋ จ

๋ชฉ์ฐจ

์–ธ์ œ๋‚˜ ์ตœ์‹  Docker

7์žฅ - 12. USER
์–ธ์ œ๋‚˜ ์ตœ์‹  Docker

USER๋Š” ๋ช…๋ น์„ ์‹คํ–‰ํ•  ์‚ฌ์šฉ์ž ๊ณ„์ •์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. RUN, CMD, ENTRYPOINT์— ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

.Dockerfile

USER nobody

USER <๊ณ„์ • ์‚ฌ์šฉ์ž๋ช…> ํ˜•์‹์ž…๋‹ˆ๋‹ค.

USER ๋’ค์— ์˜ค๋Š” ๋ชจ๋“  RUN, CMD, ENTRYPOINT์— ์ ์šฉ๋˜๋ฉฐ, ์ค‘๊ฐ„์— ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๋ฅผ ์„ค์ •ํ•˜์—ฌ ์‚ฌ์šฉ์ž๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

.Dockerfile

USER nobody
RUN touch /tmp/hello.txt

USER root
RUN touch /hello.txt
ENTRYPOINT /hello-entrypoint.sh

์ฒ˜์Œ์—๋Š” nobody ๊ณ„์ •์œผ๋กœ /tmp/hello.txt ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ๋‹ค์Œ๋ถ€ํ„ฐ๋Š” root ๊ณ„์ •์œผ๋กœ /hello.txt ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ (/์—๋Š” root ๊ณ„์ •๋งŒ ํŒŒ์ผ์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ), /hello-entrypoint.sh ํŒŒ์ผ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.


์ด์ฐฌํฌ (MarkiiimarK)
Never Stop Learning.