Docker Build Fails on Windows?

Viewed 29

On Linux I used to build docker image like this:

docker build -t ubuntu-docker:v1.0.2 ./

But on Windows 11 (PowerShell as administrator) I'm getting the following error:

PS C:\> docker build -t ubuntu-docker:v1.0.2 ./
Get-Process : A positional parameter cannot be found that accepts argument 'docker'.
At line:1 char:1
+ PS C:\> docker build -t ubuntu-docker:v1.0.2 ./
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand

PS C:\> error checking context: 'can't stat '\\?\C:\$Recycle.Bin\S-1-5-18''.

why is that and how can I fix it? I don't understand the error message

My docker file:

FROM ubuntu:22.04

RUN apt-get install -y python3-pip
COPY ./requirements.txt ./web_scraping/
RUN pip3 install -r ./web_scraping/requirements.txt
ADD ./ ./web_scraping/
CMD ["bash"]
1 Answers

./ isn't a valid path on Windows. Use . instead (which also works equally well on Linux, so if you switch over to using that, you can use the same build command on Windows and Linux).

Related