1. root@ubuntu:/test/docker# mkdir /add root@ubuntu:/test/docker# cd /add

  2. root@ubuntu:/add# touch index.html root@ubuntu:/add# echo add test > index.html

  3. root@ubuntu:/add# tar -cvf add.tar index.html

    root@ubuntu:/add# tar -cvf add.tar index.html
    index.html
    
  4. root@ubuntu:/add# rm -rf index.html

  5. root@ubuntu:/add# vi Dockerfile

    FROM nginx:latest
    
    WORKDIR /usr/share/nginx/html
    ADD add.tar .
    

    이렇게 하면 목적지의 .WORKDIR이므로 /usr/share/nginx/htmlADD된다.

    add.tar/usr/share/nginx/html로 복사된 후 압축이 해제된다.

  6. root@ubuntu:/add# docker build -t add:1.1 . root@ubuntu:/add# docker run -dp 7777:80 --name add add:1.0

  7. root@ubuntu:/add# curl localhost:7777

    root@ubuntu:/add# curl localhost:7777
    add test