0

我正在使用 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
4

2 回答 2

1

这应该工作

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

我刚刚在我的 ubuntu:latest 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
于 2016-05-20T03:58:38.517 回答
0

您可以用于 ubuntu:

cat /etc/os-release

对于高山:

cat /etc/lsb-release
于 2017-08-30T17:39:04.393 回答