git clone https://github.com/linux-do/override.git
cd override/
创建并编辑 Dockerfile
FROM golang:1.21-alpine AS builder
# 设置工作目录
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o override
FROM alpine:latest
COPY --from=builder /app/override /usr/local/bin/override
WORKDIR /app
ENTRYPOINT ["/usr/local/bin/override"]
EXPOSE 8181
编译镜像
docker build -t override-app .
启动容器并挂载 config.json
文件:
docker run -d --rm -p 127.0.0.1:8181:8181 -v $(pwd)/config.json:/app/config.json override-app
amd64的机器直接使用镜像
docker run -d --rm -p 127.0.0.1:8181:8181 -v $(pwd)/config.json:/app/config.json 2171max/override-app:latest
这里注意一点就是json配置的127.0.0.1:8181要改成0.0.0.0:8181