Dockerfile
FROM golang:alpine3.7 AS build-stageWORKDIR /go/src/mypro.exportReportCOPY . .RUN go build -tags=jsoniter -o serverFROM alpine:3.7ENV TZ=Asia/ShanghaiRUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ && apk --no-cache --update add tzdataCOPY --from=build-stage /go/src/mypro.exportReport .EXPOSE 8000CMD ["./server"]
使用Dockerfile生成镜像
docker build -t docker.image_name /Users/zhou/go/src/mypro.exportReport/// -t 对镜像命名 PS:注意小写// /Uers/zhou... Dockerfile的路径
生成容器:
docker run -p 8000:5001 --name export_excel docker.image_name:latest ./server// -p 容器内部的5001端口映射到外部8000端口// --name 命名容器名字// REPOSITORY:TAG// ./server是Dockerfile的 CMD