正在按照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文件放在my-app-master文件夹中。

docker build -f my-app-master/Dockerfile -t my-app-master

其他回答

使用以下命令

docker build -t mytag .

注意mytag和dot之间有一个空格。这个点表示当前的工作目录。

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 .**
#Using a file other than Dockerfile instead.
#Supose my file is `Dockerfile-dev`

docker build -t mytag - < Dockerfile-dev

打开PowerShelland并遵循以下说明。 这种类型的错误通常出现在Windows S.O.中 当您使用命令构建时,需要一个选项和路径。

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

试试这个:

C:\Users\Daniele\app> docker build -t friendlyhello C:\Users\Daniele\app\

Friendlyhello是分配给容器的名称 c:\ users \ daniel \app\是包含Dockerfile的路径

如果你想添加一个标签

C:\Users\Daniele\app> docker build -t friendlyhello:3.0 C:\Users\Daniele\app\

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

Docker build -t my_image -f my_dockerfile

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