Docker ubuntu 映像 - bash: man: command not found
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33050163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Docker ubuntu image - bash: man: command not found
提问by shrivb
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.
我开始使用 Docker 并且刚刚提取了一个基本的 ubuntu 映像。我在通过 docker-machine 运行 Docker 的 Windows 7 机器上。
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.
不知道为什么,我在 bash 上找不到 man 命令。我尝试将 man 的路径导出到 $PATH 但仍然没有任何乐趣。
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?
如果导出命令不起作用,不确定编辑 bashrc 是否会产生任何影响。所以还没有尝试。我还需要做些什么才能在 docker 映像上运行 man 吗?
采纳答案by Nguyen Sy Thanh Son
You have to install man
command in the container:
您必须man
在容器中安装命令:
apt-get install man
回答by Mike Wyer
Note: for a completelyfresh 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)
(我做到了:起初apt-get install man
得到E: Unable to locate package man
了)
回答by KiwenLau
Just install "man" inside container can solve your problem:
只需在容器内安装“man”即可解决您的问题:
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:
似乎“man”应该已经安装在容器中,因为您可以通过运行 whereis 命令找到“man”:
root@d16e09720264:/# whereis man
man: /usr/local/man /usr/share/man
However, you can find the result of whereis has changed after intalling "man":
但是,您可以发现在安装“man”后 whereis 的结果发生了变化:
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.
这表示默认情况下“man”未安装在容器内。至少,“man”没有正确安装。
As far as I know, "vim" shows similar result.
据我所知,“vim”显示了类似的结果。
回答by vikas bhandari
$ sudo apt-get update
$ sudo apt-get install -y man