Docker部署gin
Docker部署gin
新建一个Dockerfile:注意必须小写MAINTAINER "chengqiang"
FROM golang:1.17
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
GOPROXY="https://goproxy.cn,direct"
MAINTAINER "chengqiang"
WORKDIR /home/17_gin_demo17
ADD . /home/17_gin_demo17
RUN go build main.go
EXPOSE 8080
ENTRYPOINT ["./main"]
make_image.sh :首选运行打包的脚本
docker build -t chengqiang .
run_image.sh
docker run -p 8080:8080 chengqiang
下载镜像
上传镜像
命令函终端运行镜像文件
docker images
docker run -p 8080:8080 -d chengqiang