如何在docker中安装特定于os的软件包?(How do I install os specific packages inside docker?)

编程入门 行业动态 更新时间:2024-10-27 23:21:07
如何在docker中安装特定于os的软件包?(How do I install os specific packages inside docker?)

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

I 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.04

This 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:latest

And here is the output

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

更多推荐

本文发布于:2023-08-03 17:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1393357.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:软件包   如何在   docker   packages   os

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!