26

Am getting started with Docker and just pulled up a basic ubuntu image. I am on a windows 7 box running Docker via docker-machine.

Do not know why, I am not able to find the man command on bash. I tried exporting the path of man to $PATH but still no joy.

docker@default:~$ docker run -it ubuntu bash
root@2dd12b770666:/# man ls
bash: man: command not found
root@2dd12b770666:/# whereis man
man: /usr/local/man /usr/share/man
root@2dd12b770666:/# export PATH=/usr/local/man:/usr/share/man:$PATH
root@2dd12b770666:/# echo $PATH
/usr/local/man:/usr/share/man:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
root@2dd12b770666:/# man
bash: man: command not found
root@2dd12b770666:/#

If export command does not work, not sure if editing bashrc would have any effect. So did not try that yet. Is there anything else I need to do to be able to run man on the docker image?

shrivb
  • 1,511
  • 3
  • 15
  • 20

4 Answers4

32

You have to install man command in the container:

apt-get install man
Adrian
  • 14,931
  • 9
  • 45
  • 70
Nguyen Sy Thanh Son
  • 5,300
  • 1
  • 23
  • 33
  • 1
    Thought since /usr/share/man already contained content, man ought to be by default present. Thanks, – shrivb Oct 10 '15 at 05:00
  • @shrivb I was surprised to find that man was not available too. Only very thin Linux images will remove even the basic commands like `man` – Macindows Dec 19 '19 at 11:50
23

Note: for a completely fresh docker install, you may need:

apt-get update
apt-get install man

(I did:apt-get install man and got E: Unable to locate package man at first)

Mike Wyer
  • 231
  • 2
  • 2
2

Just install "man" inside container can solve your problem:

root@d16e09720264:/# apt-get install -y man

It seems that "man" should be already installed in container because you can find "man" by running whereis command:

root@d16e09720264:/# whereis man
man: /usr/local/man /usr/share/man

However, you can find the result of whereis has changed after intalling "man":

root@d16e09720264:/# whereis man
man: /usr/bin/man /usr/local/man /usr/share/man /usr/share/man/man1/man.1.gz

This indicates that "man" is not installed inside container by default. At least, "man" is not properly installed.

As far as I know, "vim" shows similar result.

KiwenLau
  • 2,502
  • 1
  • 19
  • 23
2
$ sudo apt-get update

$ sudo apt-get install -y man
EstevaoLuis
  • 2,422
  • 7
  • 33
  • 40
vikas bhandari
  • 408
  • 4
  • 6
  • 4
    While this might answer the authors question, it lacks some explaining words and links to documentation. Raw shell snippets are not very helpful without some phrases around it. You may also find [how to write a good answer](https://stackoverflow.com/help/how-to-answer) very helpful. Please edit your answer. – hellow Sep 04 '18 at 09:15