如何在 docker 中安装特定于操作系统的软件包



我正在使用ubuntu 15.10,并尝试使用docker来设置我的节点和mongo环境。但是由于lsb_release -a命令在 docker 中不起作用,我无法知道 ubuntu docker 映像的版本。它被标记为 ubuntu:latest 。此外/etc/lsb-release实用程序显示 docker 内部拒绝的权限。

有没有办法知道 docker 容器中存在哪个 ubuntu 版本,因为要安装 mongo,我需要版本名称来添加,例如 14.04

echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

这应该有效

RELEASE=$(cat /etc/lsb-release  | grep DISTRIB_RELEASE  | cut -d= -f2)

我刚刚在我的 ubuntu:最新的 docker 映像上尝试了它,并得到了版本 16.04

$ docker run -it ubuntu:latest /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
6d28225f8d96: Pull complete
166102ec41af: Pull complete
d09bfba2bd6a: Pull complete
c80dad39a6c0: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:5718d664299eb1db14d87db7bfa6945b28879a67b74f36da3e34f5914866b71c
Status: Downloaded newer image for ubuntu:latest

这是输出

root@9c4c1e6313ce:/# RELEASE=$(cat /etc/lsb-release  | grep DISTRIB_RELEASE  | cut -d= -f2)
root@9c4c1e6313ce:/# echo $RELEASE
16.04

你可以用于 ubuntu:

cat /etc/os-release

对于高山:

cat /etc/lsb-release

相关内容

最新更新