1、镜像的存储位置
/var/lib/docker
命令:docker info # 查看docker的详细信息
2、镜像相关操作
2.1列出镜像
$ docker images [OPTSIONS] [REPOSITORY]
-a,--all=false # 显示所有镜像
-f,--filter=[] # 显示时的过滤条件
--no-trunc=false # 不使用截断的形式来显示数据
-q,--quiet=false # 只显示镜像的唯一ID
示例:
docker images # 查看所有镜像
显示:
REPOSITORY : 镜像所属仓库名*
TAG : 镜像所属标签名*
IMACE ID : 镜像唯一ID
CREATED : 镜像创建时间
VIRTUAL SIZE : 镜像所属大小
2.2、查看镜像
docker inspect [OPTIONS] CONTAINER | IMAGE [CONTAINER | IMAGE……]
-f,--format=""
2.3、删除镜像
docker rmi[OPTIONS] IMAGE[IMAGE……]
-f, --force =false Force removal of the image
--no-prune=false Do not delete untagged parents
示例:
docker rmi [仓库id] 或者 REPOSITORY:TAG
2.4、查找镜像
Docker Hub
https://registry.hub.docker.com
$ docker search [OPTIONS] TERM
--automated=false Only show automated builds # 自动化
--no-trunc=false Don't truncate output # 如果选择了True就不以节段的方式显示
-s, --STARS=0 Only displays with at least x stars # 限定显示结果的最低星级别
示例:
sudo docker search ubuntu # 查找ubuntu相关镜像
sudo docker search -s 3 ubuntu # 查找三星以上ubuntu相关镜像
2.5、拉取镜像
docker pull [OPTIONS] NAME [:TAG]
-a, --all-tags=false Download all tagged images in the repository # 匹配到名字的镜像仓库中所有的镜像下载到本地
示例:
docker pull ubuntu:14.04
进阶版使用国内服务器
使用 --registry-mirror选项
1、修改: /etc/default/docker
2、添加:DOCKER_OPTS="--registry-mirror=http://MIRROR-ADDR"
https://www.daocloud.io
2.6、推送镜像
2.7、构建镜像

保存对容器的修改,并再次使用
自定义镜像的能力
以软件的形式打包并分发服务及其运行环境
意义
1、$ docker commit 通过容器构建
格式:$ docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAGI]]
a --author="" Author # 指定镜像的作者
e.g., "John Hannibal Smith hannibal@a-team.com"
-m,--message="" Commit message # 记录镜像构建的信息
-p,--pause=true Pause container during commit # 指示commit命令不暂停正在执行的容器
示例:
1、docker run -it -p 88 --name commit_test ubuntu/bin/bash # 启动一个名为commit_test交互式容器
2、apt-get update # 更新
3、apt-get nginx # 安装nginx
4、exit # 退出
5、ps -l # 查看建立好的容器
6、docker commit -a 'dormancypress' -n 'nginx' conit_test dormancypress/connit_test1
#-a+作者信息、-n+镜像信息、conit_test:容器名字、dormancypress/connit_test1 :镜像的名字 提交镜像
2、$ docker build 通过Dockerfile文件构建
创建第一个 Dockerfile
# First Dockerfile
FROM ubuntu : 14.04
MAINTAINER dormancypress "dormancypress@outlook.com"
RUN apt-get update
RUN apt-get install-y nginx
EXPOSE 80
示例:
1、mkdir -p dockerfile/df_test1 # 创建一个存储docker容器的文件夹
2、cd dockerfile/df_test1 # 今日文件夹
3、vim dockerfile # 新建一个文件并编辑
4、将一下存储进文件中
FROM ubuntu : 14.04
MAINTAINER dormancypress "dormancypress@outlook.com"
RUN apt-get update
RUN apt-get install-y nginx
EXPOSE 80
5、$ docker build # 构建镜像
docker build [OPTIONS] PATH | URL |- # PATH | URL |-指文件的路径
--force-rm=false
--no-cache=false
--pull=false
-,--quiet=false
--rm=true
-t,--tag="" # 执行构建出镜像的名字
示例:
docker build -t="dormancypress/df_test1"