SoFunction
Updated on 2025-03-10

Solve Docker error: "docker build" requires exactly 1 argument.

Report an error

An error occurred when building an image using docker:

[root@iZhp33j6fklnmhbf0lz2obZ ~]# docker build -t test:latest
"docker build" requires exactly 1 argument.
See 'docker build --help'.

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile

solve

When copying and pasting, be careful of the details and be sure to add spaces and dots at the end.

docker build -t test:latest .
[root@iZhp33j6fklnmhbf0lz2obZ ~]# docker build -t test:latest .
Sending build context to Docker daemon  28.76MB
Step 1/7 : FROM ubuntu:22.04
 ---> df5de72bdb3b
Step 2/7 : RUN apt-get update && apt-get install -y python3 python3-pip
 ---> Using cache
 ---> eee89b706a8b
Step 3/7 : RUN pip install flask==2.1.*
 ---> Using cache
 ---> d7b00194a3bd
Step 4/7 : COPY  /
 ---> Using cache
 ---> eaf08a89e93f
Step 5/7 : ENV FLASK_APP=hello
 ---> Using cache
 ---> 981fa111d188
Step 6/7 : EXPOSE 8000
 ---> Using cache
 ---> a6ef7a1dc59d
Step 7/7 : CMD flask run --host 0.0.0.0 --port 8000
 ---> Using cache
 ---> 90cb9f03bf34
Successfully built 90cb9f03bf34
Successfully tagged test:latest

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.