简体   繁体   English

Docker 在 Windows 上构建失败?

[英]Docker Build Fails on Windows?

On Linux I used to build docker image like this:在 Linux 上,我曾经像这样构建 docker 图像:

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

But on Windows 11 (PowerShell as administrator) I'm getting the following error:但是在 Windows 11(PowerShell 作为管理员)上,我收到以下错误:

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:我的 docker 文件:

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"]

./ isn't a valid path on Windows. ./不是 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).相反(它在 Linux 上也同样有效,所以如果你切换到使用它,你可以在 Windows 和 Linux 上使用相同的构建命令)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM