root@ubuntu:/test/docker# mkdir /add
root@ubuntu:/test/docker# cd /add
root@ubuntu:/add# touch index.html
root@ubuntu:/add# echo add test > index.html
root@ubuntu:/add# tar -cvf add.tar index.html
root@ubuntu:/add# tar -cvf add.tar index.html
index.html
root@ubuntu:/add# rm -rf index.html
root@ubuntu:/add# vi Dockerfile
FROM nginx:latest
WORKDIR /usr/share/nginx/html
ADD add.tar .
이렇게 하면 목적지의 .
은 WORKDIR
이므로 /usr/share/nginx/html
로 ADD
된다.
즉 add.tar
는 /usr/share/nginx/html
로 복사된 후 압축이 해제된다.
root@ubuntu:/add# docker build -t add:1.1 .
root@ubuntu:/add# docker run -dp 7777:80 --name add add:1.0
root@ubuntu:/add# curl localhost:7777
root@ubuntu:/add# curl localhost:7777
add test