在docker中运行特定的ubuntu

时间:2017-11-14 19:38:04

标签: ubuntu docker

我想使用具有特定ubuntu版本的docker。我有我的docker ubuntu图像:

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

现在我想用ubuntu 14.04运行一个docker:

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

当我用uname -a检查时,我发现仍有Ubuntu-16.04。

如何在docker中运行ubuntu的确切版本?

2 个答案:

答案 0 :(得分:2)

它似乎运作良好:

 ~/ 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:/#

内核在所有容器之间从主机共享。要查看正在运行的版本,请使用:cat /etc/*-release

答案 1 :(得分:0)

我认为uname报告内核版本,它在容器和主机之间共享,并且您的输出是预期的。

您可能需要查看以下链接:https://unix.stackexchange.com/questions/343717/centos7-container-on-centos6-uname-command

您也可以考虑'cat / etc / system-release'