1. Dockerfile文件内容
FROM golang:alpine RUN mkdir /app COPY . /app WORKDIR /app RUN go build -o main . CMD ["/app/main"]
2. 运行 docker build -t go-app-img . 进行build后遇到问题:
ERROR: error during connect: in the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect: Get "http://%2
F%2F.%2Fpipe%2Fdocker_engine/_ping": open //./pipe/docker_engine: The system cannot find the file specified.
尝试将dockerfile中的FROM换成阿里云依旧不行
3. 解决方案:
将dockerhub上的镜像拉到本地,再进行build
3.1 查看docker上是否有golang的镜像
docker search golang
3.2 拉取golang镜像到本地
docker pull golang:alpine
3.3 重新进行build即可,会优先使用本地镜像
4. 将build后的镜像存储到本地和重新存放到docker引擎内
查看docker引擎内部有哪些镜像:
docker images
将镜像存储到本地
docker save -o go-app-img.tar 90f0763c4823
加载本地镜像到docker中
docker load -i go-app-img.tar