修改 httpd 映像檔

  1. 使用 centos/httpd 映像檔,執行 /bin/bash,修改 httpd 映像檔。
    [root@dyw219 newimg]# docker run -it centos/httpd /bin/bash
    
  2. 進入 centos/httpd 容器後,在網頁根目錄產生 index.html 檔。
    [root@a7e9f3120658 /]# echo 'mytest' > /var/www/html/index.html
    [root@a7e9f3120658 /]# cat /var/www/html/index.html
    mytest
    
  3. 退出 centos/httpd 容器
    [root@a7e9f3120658 /]# exit
    exit
    
  4. a7e9f3120658 容器已更新,使用 docker commit 產生容器 a7e9f3120658 的新映像檔 centos/httpd,TAG 為 index,-m 提定說明訊息。
    [root@dyw219 newimg]# docker commit -m "Created index.html" a7e9f3120658 centos/httpd:index
    5bf6f66639205293fe175fd0b866c94fe24f8f06f5838f857083c121a2e9eca8
    
  5. 查看 centos/httpd 映像檔,多了 TAG 是 index 的映像檔。
    [root@dyw219 newimg]# docker images centos/httpd
    REPOSITORY      TAG        IMAGE ID         CREATED           VIRTUAL SIZE
    centos/httpd    index      5bf6f6663920     15 seconds ago    258 MB
    centos/httpd    latest     b4650389df73     7 months ago      258 MB