12

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.

Henrik Sachse
  • 51,228
  • 7
  • 46
  • 59
onizukaek
  • 1,082
  • 1
  • 14
  • 38

1 Answers1

17

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
Henrik Sachse
  • 51,228
  • 7
  • 46
  • 59
  • Thank you very much. I'm so ashamed XD, I hate typo issues. – onizukaek Jul 23 '15 at 18:52
  • That's a miss in their documentation. Any idea how to request an update to their docs? Are they on GitHub anywhere? – peinearydevelopment Jul 30 '15 at 18:51
  • You can find the documentation [here](https://github.com/docker/tutorials). They corrected it already in their master branch. – Henrik Sachse Aug 11 '15 at 11:53
  • I was unable to see the `/bin/sh: 1: /usr/games/fortunes: not found` error even after I invoked with `docker run --log-driver=json-file ...` and then `docker ps -a` to get the container ID, and then `docker logs 6b362a9f73eb`. By the way, why isn't there a `docker containers` command as analogous to `docker images`? This would help clear up the confusion some newbies have between `containers` and `images`. – user3673 Aug 09 '16 at 14:47
  • A typo is still in the documentation a year later: `https://docs.docker.com/engine/getstarted/step_four/` where it says: `FROM docker/whalesay:latest RUN apt-get -y update && apt-get install -y fortunes CMD /usr/games/fortune -a | cowsay` That's why I ran into the above problem. – user3673 Aug 09 '16 at 14:54