0

I want to use a docker with particular ubuntu version. I have my docker ubuntu images as:

ubuntu@ubuntu:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              dd6f76d9cc90        10 days ago         122MB
ubuntu              14.04               3aa18c7568fc        10 days ago         188MB

Now I want to run a docker with ubuntu 14.04:

ubuntu@ubuntu:~$ docker run -it ubuntu:14.04
root@0b004c5dc55e:/# uname -a
Linux 0b004c5dc55e 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

When I check it with uname -a I see there is still Ubuntu-16.04.

How can I run exact version of ubuntu within docker?

Opal
  • 81,889
  • 28
  • 189
  • 210
user3428154
  • 1,174
  • 5
  • 18
  • 38
  • 1
    Possible duplicate of [$(uname -a) returning the same in docker host or any docker container](https://stackoverflow.com/questions/31012297/uname-a-returning-the-same-in-docker-host-or-any-docker-container) – kichik Nov 14 '17 at 20:05

2 Answers2

3

It seems that it works well:

 ~/ docker run -it ubuntu:14.04
Unable to find image 'ubuntu:14.04' locally
14.04: Pulling from library/ubuntu
bae382666908: Pull complete 
f1ddd5e846a8: Pull complete 
90d12f864ab9: Pull complete 
a57ea72e3176: Pull complete 
783a14252520: Pull complete 
Digest: sha256:f6eed4def93a3b54da920737f0abf1a8cae2e480bb368280c898265fcaf910a3
Status: Downloaded newer image for ubuntu:14.04
root@d91b2359e1b8:/# uname -a
Linux d91b2359e1b8 4.9.44-linuxkit-aufs #1 SMP Fri Aug 25 10:00:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
root@d91b2359e1b8:/# cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.5 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
root@d91b2359e1b8:/#

The kernel is shared from the host between all containers. To view the version that is run use: cat /etc/*-release.

Opal
  • 81,889
  • 28
  • 189
  • 210
0

I think uname reports kernel version, which is shared between the container and the host, and your output is expected.

You might want to look at this link: https://unix.stackexchange.com/questions/343717/centos7-container-on-centos6-uname-command

Also you might want to consider 'cat /etc/system-release'

Chun-Yen Wang
  • 568
  • 2
  • 10
  • `cat /etc/*release` most [distros have their own file](http://linuxmafia.com/faq/Admin/release-files.html)/format – Matt Nov 14 '17 at 22:38