一,查看和删除镜像
1,列出镜像
docker images []
-a 所有镜像
-f 过滤
--no-trunc 显示不截取的id
-q只显示id
repository 仓库
tag 镜像的标签
2,查看镜像
docker inpect [options] container | image
-f,--format=""
3,删除镜像
docker rmi
-f
--no-prune
二,获取和推送镜像
1,查找镜像
docker search
--automated
--no-trunc
-s,--stars=0 显示星级
2,拉去镜像
docker pull
-a, --all
使用--redistry-mirror选项加速镜像下载速度
1,修改:/etc/default/docker
2,添加:DOCKER_OPTS="--registry-mirror=http://你申请的daocloud地址"
申请地址:http://www.daocloud.io
sudo service docker restart重新启动docker的守护进程
3,推送镜像
docker push
三,构建镜像
docker commit 通过容器构建镜像
docker build 通过dockerfile 构建镜像
1,docker commit [option] container
-a,--author 指定作者
-m,--message="" 记录信息
-P,--pause=true 指示不暂停容器构建
2,使用dockerfile构建镜像
1,创建dockerfile
#First Dockerfile
FORM ubuntu:14.04
MAINTAINER dormancypress "dormancypress@outlook.com"
RUN apt-get update
RUN apt-get install -y nginx
EXPOSE 80
2,使用docker build 命令
docker build [option] PATH | URL | -
-- force -rm
--no-cache 不使用构建缓存
--pull=false
-q,--quiet=false
-t,--tag=""指定名称
四,Dockerfile指令
FORM<image>基础镜像
FORM<image><tag>
MAINTAINER作者信息
RUN指定当前镜像中运行的命令
EXPOSE指定运行在容器上的端口,可指定多个
CMD
ADD<src><dest>具有解压功能
COPY<src><dest>
VOLUME["/data"]在容器中添加一个卷
WORKDIR /path/to/workdir
ENV<>
USER daemon
ONBUILD添加触发器,当一个镜像被其他镜像当做基础镜像时执行,会在构建过程中插入指 令。