我正在玩谷歌的Dart docker图像.我正在尝试构建一个侦听端口80的Hello World应用程序.我在Azure上的Ubuntu Server 14上运行它.
如果我运行google/dart-hello,它一切正常,我可以连接端口8080.
该google/dart-hello图像是基于对google/dart-runtime图像,其又,根据google/dart.基础图像添加了Dart; google/dart-runtime添加一个Dockerfile,它希望执行bin/server.dart并公开端口8080,并google/dart-hello提供bin/server.dart(和pubspec.yaml)使其工作.google/dart-runtime它本身没用,因为它不包含bin/server.dart或pubspec.yaml.
所以,google/dart-runtime是一个很好的基础,如果你的服务器是在bin/server.dart 和你想在8080端口上监听,因为我想为侦听端口80,我使用的google/dart图像为基础,希望能压扁什么在google/dart-runtime和google/dart-hello进入我的容器,但改为80端口.
您可以在此处找到三个Google图片的来源回购:
所以,我从中获取了Dockerfile google/dart-runtime和来自的文件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
Run Code Online (Sandbox Code Playgroud)
在与此Dockerfile相同的目录中,我有以下文件:
我用以下方法构建图像:
sudo docker build --no-cache -t dart-test .
Run Code Online (Sandbox Code Playgroud)
这是输出:
danny@linux:~/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
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试运行它(使用sudo docker run --rm -i -t dart-test),我会收到以下错误:
danny@linux:~/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)
Run Code Online (Sandbox Code Playgroud)
如果我替换了dartDockerfile中的执行/bin/bash,那么当我构建并运行时,我会进入bash,/app/但文件夹是空的.
我已尝试使用0.9(?)版本和1.2版本(一个来自apt-get docker.ioDocker网站上更多涉及的指令而来自另一个),因为我注意到在发行说明中提到了ADD修复.两者都是一样的.
我可以在网上找到大量的信息,人们经常将Dockerfile传输到STDIN,这意味着没有context,但你可以在我的输出中看到正在发送5KB的数据; 虽然它可能只是Dockerfile而我猜其他什么?它们位于同一目录中,这是一个列表:
danny@linux:~/dart_test$ dir
bin Dockerfile pubspec.lock pubspec.yaml
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1962 次 |
| 最近记录: |