【问题标题】:How do I install os specific packages inside docker?如何在 docker 中安装特定于操作系统的软件包?
【发布时间】:2016-05-20 03:50:10
【问题描述】:

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

【问题讨论】:

    标签: ubuntu docker ubuntu-15.10


    【解决方案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
    

    【讨论】:

      【解决方案2】:

      你可以用于ubuntu:

      cat /etc/os-release
      

      对于高山:

      cat /etc/lsb-release
      

      【讨论】:

        猜你喜欢
        • 2017-08-14
        • 2019-10-27
        • 2019-09-27
        • 2020-02-27
        • 2013-06-23
        • 1970-01-01
        • 1970-01-01
        • 2021-12-05
        • 1970-01-01
        相关资源
        最近更新 更多