Docker:构建自己的图像问题

oni*_*aek 12 macos image build docker boot2docker

我正在发现码头,我跟着官方网站的入门部分.但是, 当您被要求从docker文件构建新映像时,我会陷入步骤2 中的"构建您自己的映像"部分链接.我正在使用OSX Yosemite,我运行的所有内容都来自Boot2Docker终端.

这是教程中的dockerfile:

FROM docker/whalesay:latest

RUN apt-get -y update && apt-get install -y fortunes

CMD /usr/games/fortunes -a | cowsay
Run Code Online (Sandbox Code Playgroud)

我建立了图像

docker build -t docker-whale .
Run Code Online (Sandbox Code Playgroud)

apt做了它的东西,并在安装财富时向我显示以下日志

debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Run Code Online (Sandbox Code Playgroud)

这是因为没有设置TERM环境变量所以添加行

ENV TERM [term name]
Run Code Online (Sandbox Code Playgroud)

解决了这个问题,但我仍然有dkkg-prconfigure警报.无论如何,所有这些都不会破坏构建过程,但是当我执行图像时

docker run docker-whale
Run Code Online (Sandbox Code Playgroud)

鲸鱼什么也没说,而不是说财富的输出(空场),因为找不到程序

/bin/sh: 1: /usr/games/fortunes: not found
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决它,因为在构建期间一切似乎都很好

Selecting previously unselected package fortune-mod.
Preparing to unpack .../fortune-mod_1%3a1.99.1-7_amd64.deb ...
Unpacking fortune-mod (1:1.99.1-7) ...
Selecting previously unselected package fortunes-min.
Preparing to unpack .../fortunes-min_1%3a1.99.1-7_all.deb ...
Unpacking fortunes-min (1:1.99.1-7) ...
Selecting previously unselected package fortunes.
Preparing to unpack .../fortunes_1%3a1.99.1-7_all.deb ...
Unpacking fortunes (1:1.99.1-7) ...
Setting up librecode0:amd64 (3.6-21) ...
Setting up fortune-mod (1:1.99.1-7) ...
Setting up fortunes-min (1:1.99.1-7) ...
Setting up fortunes (1:1.99.1-7) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Run Code Online (Sandbox Code Playgroud)

任何已经玩过本教程的人都会有一点暗示.

h3n*_*rik 17

dpkg-preconfigure在调用之前运行以下行可以修复的错误消息apt:

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
Run Code Online (Sandbox Code Playgroud)

没有发现问题是由一个错字造成的.只需更换

CMD /usr/games/fortunes -a | cowsay
Run Code Online (Sandbox Code Playgroud)

通过:

CMD /usr/games/fortune -a | cowsay
Run Code Online (Sandbox Code Playgroud)