docker: “build” requires 1 argument. See 'dock

2019-01-16 08:50发布

Trying to follow the instructions for building a docker image from the docker website.

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

this is the error I get will following the instructions on the doc and using this 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'.

How do resolve?

9条回答
放我归山
2楼-- · 2019-01-16 09:19

Did you copy the build command from somewhere else (webpage or some other file)? Try typing it in from scratch.

I copied a build command from an AWS tutorial and pasted it into my terminal and was getting this error. It was driving me crazy. After typing it in by hand, it worked! Looking closer and my previous failed commands, I noticed the "dash" character was different, it was a thinner, longer dash character than I got if I typed it myself using the "minus/dash" key.

Bad:

sudo docker build –t foo .

Good:

sudo docker build -t foo .

Can you see the difference?.. Cut and paste is hard.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-16 09:21

You can build docker image from a file called docker file and named Dockerfile by default. It has set of command/instruction that you need in your docker container. Below command creates image with tag latest, Dockerfile should present on that location (. means present direcotry)

docker build . -t <image_name>:latest

You can specify the Dockerfile via -f if the file name in not default (Dockerfile) Sameple Docker file contents.

FROM busybox
RUN echo "hello world"
查看更多
狗以群分
4楼-- · 2019-01-16 09:25


You Need a DOT at the end...


So for example:

$ docker build -t <your username>/node-web-app .

It's a bit hidden, but if you pay attention to the . at the end...

查看更多
登录 后发表回答