0

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
guleria
  • 741
  • 2
  • 11
  • 23

2 Answers2

1

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
Vlad
  • 9,180
  • 5
  • 48
  • 67
0

You can use for ubuntu:

cat /etc/os-release

for alpine:

cat /etc/lsb-release
Thiago Falcao
  • 4,463
  • 39
  • 34