본문 바로가기
728x90
반응형

Infra/Docker_K8S43

Dockerfile 작성법8 - USER USER : 특정계정으로 실행하라. 계정도 만들어줌. root@template:~/Lab# cat Dockerfile.9 FROM centos:7 RUN ["useradd" , "sysadmin"] RUN ["whoami"] USER sysadmin RUN ["whoami"] 도커허브에서 젠킨스 예를 보라 ENV : 컨테이너 안에서 변수 ARG : docker 파일안에서 변수 선언하겠다. 예) ARG user=jenkins ARG group=jenkins root@template:~/Lab# root@template:~/Lab# docker build -t myimage:1.0 -f Dockerfile.9 . Sending build context to Docker daemon 198.7kB Step 1.. 2022. 7. 31.
Dockerfile 작성법7 - WORKDIR WORKDIR : cd 명령어다 FROM centos:centos7 WORKDIR /Hello WORKDIR world WORKDIR everyone RUN ["pwd"] 디렉토리가 없으면 만든다. root@template:~/Lab# docker build -t myimage:5.0 -f Dockerfile.8 . Step 5/5 : RUN ["pwd"] ---> Running in f27cd409de07 /Hello/world/everyone root@template:~/Lab# docker run -it --name work myimage:5.0 [root@ebcb7bb530aa everyone]# [root@ebcb7bb530aa everyone]# [root@ebcb7bb530aa everyon.. 2022. 7. 31.
Dockerfile 작성법6 - HEALTHCHECK 정상동작 여부를 체크할때 사용. root@template:~/Lab# cat Dockerfile.6 FROM ubuntu RUN apt-get -y update && apt-get -y install nginx curl EXPOSE 80 COPY index.html /var/www/html/ HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost/index.html || exit 1 80/tcp, :::80->80/tcp www1 파일을 삭제하면.... root@template:~/Lab# docker exec -it www1 /bin/bash root@01f595ee0fb2:/# root@01f595ee0fb2:/# rm -f /var.. 2022. 7. 31.
Dockerfile 작성법4 - ONBUILD 개념잡기 root@template:~/Lab# cat Dockerfile.4 FROM ubuntu RUN apt-get -y update && apt-get -y upgrade && apt-get install -y nginx EXPOSE 80 Running in 956724f8a19d Removing intermediate container 956724f8a19d ---> 1789f2c72a81 Step 4/5 : ONBUILD ADD webdata.tar /var/www/html/ Running in 64efcd562b2c Removing intermediate container 64efcd562b2c ---> f857252009f4 Step 5/5 : CMD ["nginx", "-g", "daemon off.. 2022. 7. 31.
728x90
반응형