我今天刚刚下载了Windows 10 64位的Docker工具箱。我正在看教程。当我试图使用Dockerfile构建一个映像时,我收到以下错误。

步骤:

启动Docker快速入门终端。 Testdocker创建后。 准备Dockerfile文档在“建立你自己的形象”网页链接 运行以下命令

Docker build -t Docker -whale。

错误:$ docker build -t docker-whale。

unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx C:\Users\Villanueva\Test\testdocker\Dockerfile:系统找不到指定的文件。

顺便说一句:我尝试了提到的几个选项@ https://github.com/docker/docker/issues/14339

docker info

输出:

Containers: 4
 Running: 0
 Paused: 0
 Stopped: 4
Images: 2
Server Version: 1.10.1
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 20
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
 Volume: local
 Network: bridge null host
Kernel Version: 4.1.17-boot2docker
Operating System: Boot2Docker 1.10.1 (TCL 6.4.1); master : b03e158 - Thu Feb 11 22:34:01 UTC 2016
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 996.2 MiB
Name: default
ID: C7DS:CIAJ:FTSN:PCGD:ZW25:MQNG:H3HK:KRJL:G6FC:VPRW:SEWW:KP7B
Debug mode (server): true
 File Descriptors: 32
 Goroutines: 44
 System Time: 2016-02-19T17:37:37.706076803Z
 EventsListeners: 0
 Init SHA1:
 Init Path: /usr/local/bin/docker
 Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
 provider=virtualbox

当前回答

从Windows或Linux中的命令行构建映像。

在当前目录中创建一个Docker文件。 例如, 从ubuntu 运行apt-get update 运行apt-get -y install apache2 添加。/var/www/html ENTRYPOINT apachectl -D前台 ENV名称Devops_Docker 不要以.txt扩展名保存。 在命令行下运行命令 Docker构建。- t apache2image

其他回答

安装码头工人。IO代替docker帮助了我

i.e.

apt install docker.io

我得到了这个错误(在MacBook中),尽管我使用了正确的命令来创建图像,

docker build -t testimg .

后来我发现问题出在路径上。只需导航到包含Docker文件的正确路径。只需仔细检查当前的工作目录。没什么好惊慌的!

构建dockerfile的两种方法:

你可以决定不指定要构建的文件名,而只是指定一个路径来构建它(这样做的话,文件名必须是Dockerfile,不附加扩展名,例如:docker build -t docker-whale:tag path/to/Dockerfile

or

你可以用-f指定一个文件,不管你决定使用什么扩展名(在合理的范围内。txt, .dockerfile, .dockerfile等.),例如docker build -t docker-whale:tag /path/to/file -f docker-whale.dockerfile。

如果我们的环境中有多个Docker文件,那么只有Dockerfile不能满足我们的需求。

docker build -t ihub -f Dockerfile.ihub .

因此,使用file (-f参数)命令指定docker文件(Dockerfile.ihub)。

我的案例(从Windows 10运行):

将文件重命名为myDockerFile。Dockerfile到Dockerfile(不带扩展名)。

然后在文件夹外运行这个命令:

docker build .\Docker-LocalNifi\

这对我和我的同事都适用。