简体   繁体   English

Docker:构建自己的图像问题

[英]Docker: Build your own image issue

I'm discovering docker and I followed the getting started section in the official website. 我正在发现码头,我跟着官方网站的入门部分。 However I'm getting stuck in the "Build your own image" section link in the step 2 when you are asked to build a new image from a docker file. 但是,当您被要求从docker文件构建新映像时,我会陷入步骤2中的“构建您自己的映像”部分链接 I'm working on OSX Yosemite and everything I run is from the Boot2Docker terminal. 我正在使用OSX Yosemite,我运行的所有内容都来自Boot2Docker终端。

Here's the dockerfile from the tutorial: 这是教程中的dockerfile:

FROM docker/whalesay:latest

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

CMD /usr/games/fortunes -a | cowsay

I build the image 我建立了图像

docker build -t docker-whale .

apt does its stuff and shows me the following log when installing fortunes 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: 

It happens because the TERM environment variable is not set so adding the line 这是因为没有设置TERM环境变量所以添加行

ENV TERM [term name]

solved this, however I still have the dkkg-prconfigure alert. 解决了这个问题,但我仍然有dkkg-prconfigure警报。 Anyway all this doesn't break the building process, but when I execute the image 无论如何,所有这些都不会破坏构建过程,但是当我执行图像时

docker run docker-whale

the whale says nothing instead of saying the output of fortunes (empty field) because the program was not found 鲸鱼什么也没说,而不是说财富的输出(空场),因为找不到程序

/bin/sh: 1: /usr/games/fortunes: not found

I don't know how to solve it because everything seemed to be fine during the build 我不知道如何解决它,因为在构建期间一切似乎都很好

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) ...

A little hint from anyone who already played a bit with this tutorial would be great. 任何已经玩过本教程的人都会有一点暗示。

The dpkg-preconfigure error messages you could fix with running the following line before you invoke apt : 在调用apt之前,可以通过运行以下行来修复dpkg-preconfigure错误消息:

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

The not found issue is caused by a typo. 未发现的问题是由拼写错误引起的。 Simply replace 只需更换

CMD /usr/games/fortunes -a | cowsay

by: 通过:

CMD /usr/games/fortune -a | cowsay

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

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