Docker 镜像

2019-10-08 15:44:00 浏览数 (1)

hello-world

docker pull hello-world docker images hell-world docker run hello-world

COPY hello / CMD ["/hello"]

FROM scratch

centos

docker pull centos

ADD xx.tar.xz / CMD["/bin/bash"]

docker run -it centos

RUN yum install -y xxx

image.png

千层饼

两种镜像构建方式:docker commit 、dockerfile

docker commit xx yourimagename

dockerfile

FROM centos RUN yum install -y vim CMD["/bin/bash"]

构建:.当前目录

docker build -t yourimagename .

查看镜像分层结构

docker history yourimagename

不缓存:build --no-cache

Dockerfile

FROM busybox RUN touch tempfile RUN /bin/bash -c echo "xxx" COPY testfile /

docker build -t xx . docker run -it xxx

Dockerfile 常用指令

FROM MAINTAINER COPY ADD :和COPY类似,但是如果是压缩文件,会解压 ENV EXPOSE 端口 VOLUME WORKDIR RUN CMD ENTERPOINT:CMD或docker run 之后的参数会被传递给ENTERPOINT

image.png

建议使用列表形式[]

image.png

ENTERPOINT不会被忽略,一定会执行。CMD会被忽略

imagename= xx:tag

docker tag给镜像打tag

docker tag xx xx:1.9

搭建本地registry

docker run -d -p 5000:5000 -v /myregistry:/var/lib/registry registry:2

image.png

docker push xx:5000/xx/hxx

docker 指令

docker images docker history xx docker commit xxx docker build docker tag docker pull xxx docker push xxx docker rmi xx docker search xx

0 人点赞