易學筆記-第3章 映象/3.5 建立映象
- 建立映象
- 方法1:基於已有映象建立
- 啟動一個映象並且進行修改:
[[email protected] ~]# docker run -ti ubuntu /bin/bash
[email protected]:/# touch test
[email protected]:/# exit -- d406ec07e809為容器ID
- docker commit 一個映象:
- 提交映象:
[[email protected] ~]# docker commit -m "Added a new file" -a "Docker Newbee" d406ec07e809 mynewimages
sha256:32844690210ff9a5c81b5333ec8cd0451d9922de2c27995ea45128778809226d 返回的映象ID
- 檢視新的映象:
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mynewimages latest 32844690210f 17 seconds ago 121.6 MB
docker.io/ubuntu latest 2d696327ab2e 31 hours ago 121.6 MB
docker.io/wordpress latest 2c69ebee76a8 5 days ago 408.3 MB
docker.io/centos latest 196e0ce0c9fb 5 days ago 196.6 MB
docker.io/tomcat latest 84ac1052e153 5 days ago 560 MB
docker.io/nginx latest da5939581ac8 6 days ago 108.3 MB
docker.io/mysql latest aeaed9976244 6 days ago 412.3 MB
docker.io/hello-world latest 05a3bd381fc2 7 days ago 1.84 kB
docker.io/season/fastdfs latest c6cc94c34f8e 23 months ago 205 MB
- 提交映象:
- 啟動一個映象並且進行修改:
- 方法2:基於Dockerfile建立
- 方法3:基於本地模板匯入
- 模板下載地址:使用OPENVZ提供的模板來建立,下載地址為:http://openvz.org/Download/templates/preceated
- 如下載了一個ubuntu-14.04的模板壓縮包,可以使用以下命令匯入:
cat ubuntu-14.04-x86_64-minimal.tar.gz|docker import - ubuntu:14.04