我正在使用ubuntu 15.10并试图使用docker来设置我的节点和mongo环境。 但由于lsb_release -a命令在lsb_release -a中不起作用,我无法知道ubuntu docker image的版本。 它被标记为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.listI am using ubuntu 15.10 and was trying to use docker to setup my node and mongo environments. But since lsb_release -a command doesn't work inside docker I was not able to know the version of ubuntu docker image has. It was tagged as ubuntu:latest. Also /etc/lsb-release utility shows permission denied inside docker.
Is there a way to know which ubuntu version is present inside docker container because for installing mongo I need the name of version to add e.g. for 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.04This should work
RELEASE=$(cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d= -f2)I just tried it on my ubuntu:latest docker image and got version 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:latestAnd here is the output
root@9c4c1e6313ce:/# RELEASE=$(cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d= -f2) root@9c4c1e6313ce:/# echo $RELEASE 16.04更多推荐
发布评论