1. root@ubuntu:~# mkdir /docker root@ubuntu:~# cd /docker root@ubuntu:/docker#

  2. root@ubuntu:/docker# vi Dockerfile

    FROM nginx:latest
    
  3. root@ubuntu:/docker# docker build -t my_nginx:1.0 .

    root@ubuntu:/docker# docker build -t my_nginx:1.0 .
    Sending build context to Docker daemon  2.048kB
    Step 1/1 : FROM nginx:latest
     ---> 88736fe82739
    Successfully built 88736fe82739
    Successfully tagged my_nginx:1.0
    
  4. root@ubuntu:/docker# docker images

    root@ubuntu:/docker# docker images
    REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
    httpd        latest    8653efc8c72d   2 weeks ago     145MB
    my_nginx     1.0       88736fe82739   2 weeks ago     142MB
    nginx        latest    88736fe82739   2 weeks ago     142MB
    centos       7         eeb6ee3f44bd   14 months ago   204MB
    
  5. root@ubuntu:/docker# docker run -d --name my_nginx -p 555:80 my_nginx:1.0

    root@ubuntu:/docker# docker run -d --name my_nginx -p 555:80 my_nginx:1.0
    339ac219b3a7bd0c91917407f32c2181be15a59c09854b70f8c3bc5b7e828152
    
  6. root@ubuntu:/docker# curl localhost:555

    root@ubuntu:/docker# curl localhost:555
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
    html { color-scheme: light dark; }
    body { width: 35em; margin: 0 auto;
    font-family: Tahoma, Verdana, Arial, sans-serif; }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="<http://nginx.org/>">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="<http://nginx.com/>">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>
    
  7. root@ubuntu:/docker# docker tag my_nginx:1.0 beyondthemist/my_nginx:1.0 root@ubuntu:/docker# docker image ls

    root@ubuntu:/docker# docker tag my_nginx:1.0 beyondthemist/my_nginx:1.0
    root@ubuntu:/docker# docker image ls
    REPOSITORY               TAG       IMAGE ID       CREATED         SIZE
    httpd                    latest    8653efc8c72d   2 weeks ago     145MB
    beyondthemist/my_nginx   1.0       88736fe82739   2 weeks ago     142MB
    my_nginx                 1.0       88736fe82739   2 weeks ago     142MB
    nginx                    latest    88736fe82739   2 weeks ago     142MB
    centos                   7         eeb6ee3f44bd   14 months ago   204MB
    

    내가 만든 docker image에 tag를 붙인다.

  8. root@ubuntu:/docker# docker push beyondthemist/my_nginx:1.0

    root@ubuntu:/docker# docker push beyondthemist/my_nginx:1.0
    The push refers to repository [[docker.io/beyondthemist/my_nginx](<http://docker.io/beyondthemist/my_nginx>)]
    6cffb086835a: Mounted from library/nginx
    e2d75d87993c: Mounted from library/nginx
    5a5bafd53f76: Mounted from library/nginx
    f86e88a471f4: Mounted from library/nginx
    f7ed3797e296: Mounted from library/nginx
    ec4a38999118: Mounted from library/nginx
    1.0: digest: sha256:6ad8394ad31b269b563566998fd80a8f259e8decf16e807f8310ecc10c687385 size: 1570
    

    방금 tag를 붙인 docker image를 내 repository에 업로드한다.

    이 작업을 하려면 Docker hub에 로그인이 되어 있어야 한다. → root@ubuntu:/docker# docker login

    Untitled

  9. repository 삭제

    Untitled

    Untitled

    밑에 [Delete repository] 버튼 누르고 이름 한 번 더 입력하면 삭제됨

  10. root@ubuntu:/docker# vi Dockerfile

    FROM nginx:latest
    
    COPY index.html /usr/share/nginx/html/index.html
    WORKDIR /usr/share/nginx.html
    
  11. root@ubuntu:/docker# docker image rm -f my_nginx:1.0 root@ubuntu:/docker# docker image rm -f beyondthemist/my_nginx:1.0

    root@ubuntu:/docker# docker image rm -f my_nginx:1.0
    Untagged: my_nginx:1.0
    root@ubuntu:/docker# docker image rm -f beyondthemist/my_nginx:1.0
    Untagged: beyondthemist/my_nginx:1.0
    Untagged: beyondthemist/my_nginx@sha256:6ad8394ad31b269b563566998fd80a8f259e8decf16e807f8310ecc10c687385
    

    여기서 표시되는 beyondthemist/my_nginx:1.0와 ****Docker hub에서 표시되는 그것은 별개다.

  12. root@ubuntu:/docker# docker build -t my_nginx:1.1 .

    root@ubuntu:/docker# docker build -t my_nginx:1.1 .
    Sending build context to Docker daemon  3.072kB
    Step 1/3 : FROM nginx:latest
     ---> 88736fe82739
    Step 2/3 : COPY index.html /usr/share/nginx/html/index.html
     ---> afb5883ff029
    Step 3/3 : WORKDIR /usr/share/nginx.html
     ---> Running in f0795a3831a7
    Removing intermediate container f0795a3831a7
     ---> 8a3991c34dae
    Successfully built 8a3991c34dae
    Successfully tagged my_nginx:1.1
    
  13. root@ubuntu:/docker# docker run -dp 999:80 --name my_nginx my_nginx:1.1

    root@ubuntu:/docker# docker run -dp 999:80 --name my_nginx my_nginx:1.1
    7d04b3d9dba9aac446fc95a9da62ddf9136508e283a3637191927bd72189fa68
    
  14. root@ubuntu:/docker# curl localhost:999

    root@ubuntu:/docker# curl localhost:999
    dockerfile