Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verify the version of ubuntu running in a Docker container

I have Docker Toolbox installed on windows 8.1 and I am creating an image based on ubuntu:latest (which should be 16.04). I want to make sure that my application is indeed run on 16.04. Here is my Dockerfile:

FROM ubuntu:latest
MAINTAINER xyz [email protected]
COPY apt.conf /etc/apt/
RUN apt-get -y update 
RUN apt-get -y  install cmake
RUN mkdir /usr/local/
COPY folder /usr/local/
RUN mkdir /usr/local/build
CMD cd /usr/local/build
CMD cmake /usr/local/

Once the image is built, i try to run :

docker run image uname -r

But it always returns with 4.4.12 boot2docker

Now i know that boot2docker is the lightweight linux VM on top of which containers are spun on windows, however shouldn't running the image give me version of ubuntu it's running? How can i verify this?

like image 481
user1411110 Avatar asked Jun 23 '16 22:06

user1411110


People also ask

What version of Ubuntu does Docker use?

OS requirements. To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions: Ubuntu Jammy 22.04 (LTS) Ubuntu Impish 21.10.

How can I tell if Docker is running Ubuntu?

The operating-system independent way to check whether Docker is running is to ask Docker, using the docker info command. You can also use operating system utilities, such as sudo systemctl is-active docker or sudo status docker or sudo service docker status , or checking the service status using Windows utilities.

How do I determine Ubuntu version?

Open your terminal either by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon. Use the lsb_release -a command to display the Ubuntu version. Your Ubuntu version will be shown in the Description line. As you can see from the output above, I am using Ubuntu 18.04 LTS.

Which is the Docker command to show the version?

docker -v only shows the client version. docker version will show both client and server version.


2 Answers

The uname command is pulling specs from the kernel running on the host. If I enter a Ubuntu container on my Debian host, the uname will answer with a Debian build of the kernel.

To know the version of Ubuntu you are running, do a

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"

It's simple variables that are shell script friendly, so you can run

#!/bin/sh

if [ ! -f /etc/lsb-release ]; then
  echo "lsb-release missing, unlikely to be a Ubuntu system"
  exit 1
fi
. /etc/lsb-release
if [ "$DISTRIB_ID" != "Ubuntu" -o "$DISTRIB_RELEASE" != "16.04" ]; then
  echo "Linux install doesn't appear to be Ubuntu 16.04"
  exit 1
fi
...
like image 122
BMitch Avatar answered Oct 24 '22 03:10

BMitch


Try this

cat /etc/os-release

It will return like this

NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
like image 24
Bluethon Avatar answered Oct 24 '22 05:10

Bluethon