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 er
From the command run:
sudo docker build -t myrepo/redis
there are no "arguments" passed to the docker build
command, only a single flag -t
and a value for that flag. After docker parses all of the flags for the command, there should be one argument left when you're running a build.
That argument is the build context. The standard command includes a trailing dot for the context:
sudo docker build -t myrepo/redis .
Every docker build sends a directory to the build server. Docker is a client/server application, and the build runs on the server which isn't necessarily where the docker command is run. Docker uses the build context as the source for files used in COPY
and ADD
steps. When you are in the current directory to run the build, you would pass a .
for the context, aka the current directory. You could pass a completely different directory, even a git repo, and docker will perform the build using that as the context, e.g.:
docker build -t sudobmitch/base:alpine --target alpine-base \
'https://github.com/sudo-bmitch/docker-base.git#main'
For more details on these options to the build command, see the docker build documentation.
If you are including the value for the build context (typically the .
) and still see this error message, you have likely passed more than one argument. Typically this is from failing to parse a flag, or passing a string with spaces without quotes. Possible causes for docker to see more than one argument include:
Missing quotes around a path or argument with spaces (take note using variables that may have spaces in them)
Incorrect dashes in the command: make sure to type these manually rather than copy and pasting
Incorrect quotes: smart quotes don't work on the command line, type them manually rather than copy and pasting.
Whitespace that isn't white space, or that doesn't appear to be a space.
Most all of these come from either a typo or copy and pasting from a source that modified the text to look pretty, breaking it for using as a command.
The easiest way I have to debug this, run the command without any other flags:
docker build .
Once that works, add flags back in until you get the error, and then you'll know what flag is broken and needs the quotes to be fixed/added or dashes corrected, etc.
My problem was the Dockerfile.txt needed to be converted to a Unix executable file. Once I did that that error went away.
You may need to remove the .txt portion before doing this, but on a mac go to terminal and cd into the directory where your Dockerfile is and the type
chmod +x "Dockerfile"
And then it will convert your file to a Unix executable file which can then be executed by the Docker build command.
Open PowerShelland and follow these istruction. This type of error is tipically in Windows S.O. When you use command build need an option and a path.
There is this type of error becouse you have not specified a path whit your Dockerfile.
Try this:
C:\Users\Daniele\app> docker build -t friendlyhello C:\Users\Daniele\app\
if you want to add a tag
C:\Users\Daniele\app> docker build -t friendlyhello:3.0 C:\Users\Daniele\app\
Use the following command
docker build -t mytag .
Note that mytag and dot has a space between them . This dot represents the present working directory .
In case anyone is running into this problem when trying to tag -t
the image and also build it from a file that is NOT named Dockerfile
(i.e. not using simply the .
path), you can do it like this:
docker build -t my_image -f my_dockerfile .
Notice that docker expects a directory as the parameter and the filename as an option.
Docker Build Command Format
In your powershell : There is this type of error because you have not specified a path whith your Dockerfile.
Try this:
$ docker build -t friendlyhello:latest -f C:\\TestDockerApp\\Dockerfile.txt
friendlyhello is the name you assign to your container and add the version , just use the :latest
-f C:\TestDockerApp\Dockerfile.txt - you want to add a tag because the build command needs a parameter or tag - The DockerFile is a text document so explicitly add the extension .txt
**Try this format :
$ docker build -t friendlyhello:latest -f C:\\TestDockerApp\\Dockerfile.txt .**