"Dockerfile 여러줄 파일 생성하기"의 두 판 사이의 차이

3번째 줄: 3번째 줄:
;Dockerfile 여러줄 파일 생성하기
;Dockerfile 여러줄 파일 생성하기


==방법 1: 중괄호 ==
==방법 1: 중괄호 ==
* bash(debian), sh(alpine)에서 모두 사용가능
<syntaxhighlight lang='console'>
<syntaxhighlight lang='console'>
tester@localhost:~/temp1$ cat Dockerfile
tester@localhost:~/temp1$ cat Dockerfile

2020년 10월 8일 (목) 13:39 판

1 개요

How to write commands with multiple lines in Dockerfile
Dockerfile 여러줄 파일 생성하기

2 방법 1: 중괄호 ★

  • bash(debian), sh(alpine)에서 모두 사용가능
tester@localhost:~/temp1$ cat Dockerfile
FROM alpine
RUN set -x; \
{ \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=60'; \
} > /tmp/php.ini \
&& cat /tmp/php.ini
tester@localhost:~/temp1$ docker build -t test1 .
Step 1/2 : FROM alpine
latest: Pulling from library/alpine
df20fa9351a1: Pull complete
Digest: sha256:185518070891758909c9f839cf4ca393ee977ac378609f700f60a771a2dfe321
Status: Downloaded newer image for alpine:latest
 ---> a24bb4013296
Step 2/2 : RUN set -x; { echo 'opcache.memory_consumption=128'; echo 'opcache.interned_strings_buffer=8'; echo 'opcache.max_accelerated_files=4000'; echo 'opcache.revalidate_freq=60'; } > /tmp/php.ini && cat /tmp/php.ini
 ---> Running in 79e419624a7e
+ echo 'opcache.memory_consumption=128'
+ echo 'opcache.interned_strings_buffer=8'
+ echo 'opcache.max_accelerated_files=4000'
+ echo 'opcache.revalidate_freq=60'
+ cat /tmp/php.ini
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
Removing intermediate container 79e419624a7e
 ---> 6399defa315d
Successfully built 6399defa315d
Successfully tagged test1:latest

3 방법 2: 따옴표

tester@localhost:~/temp1$ cat Dockerfile
FROM debian
RUN set -x \
&& echo "\
opcache.memory_consumption=128\n\
opcache.interned_strings_buffer=8\n\
opcache.max_accelerated_files=4000\n\
opcache.revalidate_freq=60" > /tmp/php.ini \
&& cat /tmp/php.ini
tester@localhost:~/temp1$ cat Dockerfile
Step 1/2 : FROM debian
 ---> f6dcff9b59af
Step 2/2 : RUN set -x && echo "opcache.memory_consumption=128\nopcache.interned_strings_buffer=8\nopcache.max_accelerated_files=4000\nopcache.revalidate_freq=60" > /tmp/php.ini && cat /tmp/php.ini
 ---> Running in 0ad3fea1ece3
+ echo opcache.memory_consumption=128\nopcache.interned_strings_buffer=8\nopcache.max_accelerated_files=4000\nopcache.revalidate_freq=60
+ cat /tmp/php.ini
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
Removing intermediate container 0ad3fea1ece3
 ---> f2d024a63785
Successfully built f2d024a63785
Successfully tagged test1:latest

4 같이 보기

5 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}