Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I'm working on OSX Yosemite and everything I run is from the Boot2Docker terminal.

Here's the dockerfile from the tutorial:

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

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

ENV TERM [term name]

solved this, however I still have the dkkg-prconfigure alert. 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.

like image 761
onizukaek Avatar asked Jul 23 '15 18:07

onizukaek


1 Answers

The dpkg-preconfigure error messages you could fix with running the following line before you invoke apt:

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
like image 90
Henrik Sachse Avatar answered Oct 03 '22 01:10

Henrik Sachse