构建Go项目的Docker失败了

huangapple go评论115阅读模式
英文:

docker build go project failed

问题

我尝试使用Docker构建一个Go语言项目。我按照这个项目的步骤进行操作,并成功地通过go build -o qnmahjong构建了项目。但是当我运行docker build -t qnmahjong时,它给出了一个错误提示:"docker buildx build"需要正好1个参数。我不确定是输出文件无效,还是docker命令没有将输出文件视为1个参数。

英文:

https://github.com/shuimuliang/qnmahjongserver

I tried to build a golang project with Docker. I have followed the steps from this project and successfully build the project by go build -o qnmahjong . But when I run docker build -t qnmahjong . It gives me error: "docker buildx build" requires exactly 1 argument.
I am not sure is that the output file is invalid or the docker command does not treat the output file as 1 argument.

答案1

得分: 5

docker build -t qnmahjong 替换为docker build -t qnmahjong .

你漏掉了“.”点号,点号表示你使用本地目录中的Dockerfile。

这将根据Dockerfile中的指令创建一个名为qnmahjong的Docker镜像。然后,你可以使用以下命令运行该镜像:

docker run qnmahjong
英文:

Replace docker build -t qnmahjong with docker build -t qnmahjong .

You are missing the "." The dot means you use the Dockerfile in the local directory

This will create a Docker image named qnmahjong based on the instructions in the Dockerfile. You can then run the image using the following command:

docker run qnmahjong 

huangapple
  • 本文由 发表于 2023年7月10日 16:34:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76652039.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定