docker构建镜像

Docker 提供了两种构建镜像的方法:

docker commit 命令
Dockerfile 构建文件

示例:

FROM golang:1.7.5 #基础镜像

RUN apt-get update #运行apt-get update命令创建一个新的层
RUN apt-get install -y autoconf

ENV GOPATH /gopath #定义环境变量
ENV CODIS ${GOPATH}/src/github.com/CodisLabs/codis #/gopath/src/github.com/CodisLabs/codis
ENV PATH ${GOPATH}/bin:${PATH}:${CODIS}/bin #/gopath/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/gopath/src/github.com/CodisLabs/codis/bin
COPY . ${CODIS} 将文件从 build context 复制到镜像。这是时将build context 下的内容复制到${CODIS}路径下

RUN make -C ${CODIS} distclean #make -c 指定读取makefile的目录。distclean,build-all是参数,makefile文件里面可以找到,
RUN make -C ${CODIS} build-all

WORKDIR /codis #为后面的 RUN, CMD, ENTRYPOINT, ADD 或 COPY 指令设置镜像中的当前工作目录。https://www.cnblogs.com/CloudMan6/p/6864000.html

参考:https://www.cnblogs.com/CloudMan6/p/6830067.html

https://www.cnblogs.com/CloudMan6/p/6864000.html

猜你喜欢

转载自www.cnblogs.com/sosogengdongni/p/10025624.html