简体   繁体   English

从本地 Dockerfile 构建 Docker 挂起(Windows 10)

[英]Docker build from local Dockerfile hangs (Windows 10)

I'm brand new to Docker, and I'm trying to run a Dockerfile on my Windows 10 machine, but it's hanging initially and not doing anything.我是 Docker 的新手,我正在尝试在我的 Windows 10 机器上运行 Dockerfile,但它最初挂起并且没有做任何事情。

My Dockerfile:我的 Dockerfile:

FROM busybox:latest
CMD ["date"]

My command from docker我来自 docker 的命令

$ docker build -f /projects/docker_test .

Other things of note:其他注意事项:

Docker Toolbox installed on Windows 10 Home edition安装在 Windows 10 家庭版上的 Docker 工具箱

Environmental variable:环境变量:

HOME = G:\projects\

Dockerfile location: Dockerfile 位置:

G:\projects\docker_test\Dockerfile 

File created initially with Notepad.最初使用记事本创建的文件。

EDIT: I am able to load other docker containers just fine.编辑:我能够加载其他 docker 容器就好了。 Docker simply hangs when I try to access a local Dockerfile.当我尝试访问本地 Dockerfile 时,Docker 只是挂起。

对我.dockerignore是添加一个.dockerignore文件并在那里添加不属于构建图像的文件夹(在我的例子中是/node_modules )。

The -f option is used to specify the path to the Dockerfile. -f 选项用于指定 Dockerfile 的路径。

Try with:尝试:

docker build -t docker_test -f /projects/docker_test/Dockerfile /projects/docker_test

or:或者:

cd G:\projects\docker_test\
docker build -t docker_test .

The reason for this is If we have any other folders or nested folders and files present in the same directory.原因是如果我们在同一目录中存在任何其他文件夹或嵌套文件夹和文件。 Then this is happening and resolution is either to add .dockerignorefile or just move it to a folder and then move to that folder from command prompt and then execute docker build command.然后发生这种情况,解决方案是添加 .dockerignorefile 或将其移动到一个文件夹,然后从命令提示符移动到该文件夹​​,然后执行 docker build 命令。

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

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