我在玩Google's Dart docker image。我正在尝试构建一个侦听端口80的Hello World应用程序。我在Azure上的Ubuntu Server 14上运行它。为什么Docker不向我的容器添加文件?
如果我运行google/dart-hello
,这一切工作正常,我可以在8080端口上
连接google/dart-hello
图像是基于google/dart-runtime
形象,这是反过来,基于google/dart
上。基本图像添加了Dart; google/dart-runtime
添加了Dockerfile,该Dockerfile预计执行bin/server.dart
并显示端口8080,google/dart-hello
提供bin/server.dart
(和pubspec.yaml
)以使其工作。因为它不包含bin/server.dart
或pubspec.yaml
,所以它本身没有用处。
所以,google/dart-runtime
是一个很好的基础,如果你的服务器是在bin/server.dart
和要在8080端口上监听,因为我想在端口80听,我使用的google/dart
图像为基础,希望能壁球什么在google/dart-runtime
和google/dart-hello
到我的容器,而是改为端口80
你可以找到三个谷歌图像这里的回购来源:
所以,我已经采取了从google/dart-runtime
的Dockerfile和google/dart-hello
的文件,所以我有以下几点:
FROM google/dart
WORKDIR /app
ONBUILD ADD pubspec.yaml /app/
ONBUILD ADD pubspec.lock /app/
ONBUILD RUN pub get
ONBUILD ADD . /app
ONBUILD RUN pub get
CMD []
ENTRYPOINT ["/usr/bin/dart", "/app/bin/server.dart"]
EXPOSE 80
在同目录作为这个Dockerfile,我有以下文件:
- 斌/ server.dart
- pubspec.yaml
- pubspec.lock
我正在创建的图像用:
sudo docker build --no-cache -t dart-test .
而这里的输出:
[email protected]:~/dart_test$ sudo docker build --no-cache -t dart-test .
Sending build context to Docker daemon 5.632 kB
Sending build context to Docker daemon
Step 0 : FROM google/dart
---> cd92c7fff717
Step 1 : WORKDIR /app
---> Running in d163d2597eba
---> 2802d6769b76
Removing intermediate container d163d2597eba
Step 2 : ONBUILD ADD pubspec.yaml /app/
---> Running in 7b8be2a481c2
---> 096cbe12a2cd
Removing intermediate container 7b8be2a481c2
Step 3 : ONBUILD ADD pubspec.lock /app/
---> Running in 6ae0243b0dee
---> 80f20ebafa87
Removing intermediate container 6ae0243b0dee
Step 4 : ONBUILD RUN pub get
---> Running in 621d4ce5c7f1
---> 89a509d41b11
Removing intermediate container 621d4ce5c7f1
Step 5 : ONBUILD ADD . /app
---> Running in 4de26a33487f
---> b69c65f12441
Removing intermediate container 4de26a33487f
Step 6 : ONBUILD RUN pub get
---> Running in f7cc689f6f81
---> 2ccc79ea6d04
Removing intermediate container f7cc689f6f81
Step 7 : CMD []
---> Running in 10bd31eb6679
---> f828267f00b5
Removing intermediate container 10bd31eb6679
Step 8 : ENTRYPOINT ["/usr/bin/dart", "/app/bin/server.dart"]
---> Running in 013d3ca0f25d
---> a63b59f9fd05
Removing intermediate container 013d3ca0f25d
Step 9 : EXPOSE 80
---> Running in 4301c572e598
---> 75a4317c135c
Removing intermediate container 4301c572e598
Successfully built 75a4317c135c
但是,如果我尝试运行此操作(使用sudo docker run --rm -i -t dart-test
),则会出现以下错误:
[email protected]:~/dart_test$ sudo docker run -i -t --rm dart-test
Unhandled exception:
Uncaught Error: FileSystemException: Cannot open file, path = '/app/bin/server.dart' (OS Error: No such file or directory, errno = 2)
如果我替换Dockerfile的dart
执行与/bin/bash
代替,后来当我建立和运行,我得到投入bash
在/app/
但该文件夹是空。
我试过这个0.9(?)版本和1。2(其中一个来自apt-get docker.io
,另一个来自Docker网站上的更多参与指令),因为我注意到在发行说明中提到了ADD修复。两者都是一样的。
我可以在网上找到大量的信息,人们经常将Dockerfile管入STDIN,这意味着没有context
,但是您可以在我的输出中看到正在发送5KB数据;虽然有可能这只是Dockerfile,我猜想没有其他的东西?他们是在同一个目录,这里有一个清单:当您创建一个稍后将由另一Dockerfile使用的基本映像(见documentation)
[email protected]:~/dart_test$ dir
bin Dockerfile pubspec.lock pubspec.yaml
哦,那人一点都不迷惑! :)现在就试试吧! – 2014-09-18 17:51:32
太棒了;发现!谢谢:) – 2014-09-18 17:57:19
对于所有似乎包含这些添加的输出(并创建临时图像?),我有点困惑,如果它没有真的做任何事情! – 2014-09-18 18:05:16