正在按照docker网站上的说明构建docker映像。

https://docs.docker.com/examples/running_redis_service/

这是我得到的错误将遵循文档上的说明,并使用这个Dockerfile

FROM        ubuntu:14.04
RUN         apt-get update && apt-get install -y redis-server
EXPOSE      6379
ENTRYPOINT  ["/usr/bin/redis-server"]


sudo docker build -t myrepo/redis
docker: "build" requires 1 argument. See 'docker build --help'.

如何解决?


当前回答

Docker构建命令格式

在powershell中: 出现这种类型的错误是因为您没有在Dockerfile中指定路径。

试试这个:

$ docker build -t friendlyhello:latest -f C:\\TestDockerApp\\Dockerfile.txt

Friendlyhello是你分配给你的容器的名称,并添加版本,只需使用:latest

- f C: \ TestDockerApp \ Dockerfile.txt -你想添加一个标签,因为构建命令需要一个参数或标签 DockerFile是一个文本文档,所以明确添加扩展名。txt

**尝试以下格式:

$ docker build -t friendlyhello:latest -f C:\\TestDockerApp\\Dockerfile.txt .**

其他回答

我在管道脚本中使用Docker与Jenkins管道时得到了这个错误。解决方案是在管道脚本中使用以下语法:

docker.build("[my_docker_image_tag]", "-f ./path/to/my/Dockerfile.jvm .")

Docker构建命令格式

在powershell中: 出现这种类型的错误是因为您没有在Dockerfile中指定路径。

试试这个:

$ docker build -t friendlyhello:latest -f C:\\TestDockerApp\\Dockerfile.txt

Friendlyhello是你分配给你的容器的名称,并添加版本,只需使用:latest

- f C: \ TestDockerApp \ Dockerfile.txt -你想添加一个标签,因为构建命令需要一个参数或标签 DockerFile是一个文本文档,所以明确添加扩展名。txt

**尝试以下格式:

$ docker build -t friendlyhello:latest -f C:\\TestDockerApp\\Dockerfile.txt .**

在我的例子中,我使用了一个破折号(稍微长一点的连字符)符号——在t选项出现问题之前。

docker build –t simple-node .

替换为连字符/减号。

docker build -t simple-node .

只需要在命令的末尾加上一个空格。

例子:

命令:docker build -t "blink:v1"。

在这里你可以看到“blink:v1”然后一个空格然后点(.)

这是它。

如果有人在尝试标记-t图像时遇到这个问题,并且还从一个不命名为Dockerfile的文件构建它(即不是简单地使用Dockerfile)。Path),你可以这样做:

Docker build -t my_image -f my_dockerfile

注意,docker期望将目录作为参数,将文件名作为选项。