一.查看和刪除鏡像
1.Docker Image 鏡像
- 容器的基石
- 層疊的只讀文件系統
- 聯合加載(union mount) (存儲位置 /var/lib/docker)
docker info
2.列出鏡像
docker images [OPTIONS] [REPOSITORY]
-a,--all=false 默認並不顯示中間層鏡像
-f,--filter=[] 過濾條件
-no-trunc=false 不以截斷的形式顯示數據(鏡像的唯一Id)
-q,--quiet=false 只顯示鏡像的唯一Id
Repository + Tag 完整的鏡像名,對應一個唯一的鏡像Id
3.查看鏡像
docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]
4.刪除鏡像
docker rmi [OPTIONS] IMAGE [IMAGE...]
-f,--force=false Force removal of the image
--no-prune=false Do not delete untagged parents
二.獲取和推送鏡像
1.查找鏡像
Docker Hub: https//registry.hub.docker.com
docker search [OPTIONS] TERM
--automated=false Only show automated builds
--no-trun=false Don't truncate output
-s,--start=0 Only displays with at least x starts
2.拉取鏡像
docker pull [OPTIONS] NAME [:TAG]
-a.--all-tags=false Download all tagged images in the repository
3.使用鏡像代理
使用 --registry-mirror 選項
1.修改: /etc/default/docker
2.添加: DOCKER_OPTS = "--registry-mirror=http://MIRROR-ADDR"
(https://www.daocloud.io)
4.推送鏡像
docker push NAME[:TAG]
輸入DockerHub上的用戶名,密碼,注冊郵箱
三.構建鏡像
1.通過容器來構建鏡像
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
-a, --authof="" Author. eg. "John Hannibal Smith Hannibal@a-team.com"
-m,--message="" Commit message
-p,--pause=true Pause container during commit 暫停正在執行的容器
eg. docker commit -a 'haidong' -m 'nginx' 容器id/name(需要提交的容器) dockerHub上的名字+容器名字(鏡像名字)
2.通過Dockerfile文件構建
docker build [OPTIONS] PATH | URL | - (path,url指dockerfile構建的文件路徑)
--force-rm=false
--no-cache=false
--pull=false
-q,--quiet=false
--rm=true
-t,--tag="" 制定構建出鏡像的名字
- 創建Dockerfile
#First Dockerfile FROM ubuntu:14.04 MAINTAINER dormancypress "dormancypress@outlook.com" RUN apt-get update RUN apt-get install -y nginx EXPOSE 80
- 使用 docker build 命令
docker build -t='dormancypress/df_test1' .(.表示當前目錄)