ADD의 장점 copy, url, gz은 압축을 풀어서 컨테이너에 넣어준다
1.도커파일 생성
root@hostos1:~/DockerLabs/sed/webapp# vi Dockerfile
FROM ubuntu:14.04
MAINTAINER "ayk <yg1700@naver.com>"
LABEL "purpose"="webserver practice"
RUN apt-get update && apt-get install -y apache2 \
vim \
curl
ADD webapp.tar.gz /var/www/html
WORKDIR /var/www/html
EXPOSE 80
RUN sed -i 's|Docker Container Application by kevin.lee "hylee@dshub.cloud"|Docker Cont
ainer Application by ayk "yg1700@naver.com" |g' index.html
CMD /usr/sbin/apache2ctl -D FOREGROUND
2.빌드
root@hostos1:~/DockerLabs/sed/webapp# DOCKER_BUILDKIT=1 docker build -t myhttp:1.0 .
[+] Building 67.4s (10/10) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 457B 0.0s
=> [internal] load .dockerignore 0.0s
3.빌드 이미지 확인
root@hostos1:~/DockerLabs/sed/webapp# docker images | grep myhttp
myhttp 1.0 91c00e4f207e 23 minutes ago 264MB
root@hostos1:~/DockerLabs/sed/webapp# docker image history myhttp:1.0
IMAGE CREATED CREATED BY SIZE COMMENT
91c00e4f207e 23 minutes ago CMD ["/bin/sh" "-c" "/usr/sbin/apache2ctl -D… 0B buildkit.dockerfile.v0
<missing> 23 minutes ago RUN /bin/sh -c sed -i 's|Docker Container Ap… 731B buildkit.dockerfile.v0
<missing> 23 minutes ago EXPOSE map[80/tcp:{}] 0B buildkit.dockerfile.v0
4.실행
root@hostos1:~/DockerLabs/sed/webapp# docker run -d -p 8010:80 --name myhttp1 myhttp:1.0
5.확인
root@hostos1:~/DockerLabs/sed/webapp# docker exec -it myhttp1 bash
root@1cb3ecba3564:/var/www/html# apt-get -y install tree
root@1cb3ecba3564:/var/www/html# ls
css index.html pngs
root@1cb3ecba3564:/var/www/html# tree
.
|-- css
| `-- bootstrap.css
|-- index.html
`-- pngs
|-- docker.png
`-- docker_logo.png
2 directories, 4 files
짜잔 정상적으로 apache2 컨테이너가 실행되고 있다