使用Docker安装Ubuntu

Ubuntu是以桌面应用为主的GNU/Linux开源操作系统,官方译名“友邦拓”,另有“乌班图”等译名。Ubuntu每6个月会发布一个新版本,每两年会推出一个长期支持(Long Term Support,LTS)版本,一般支持3年时间。

Ubuntu相关的镜像很多,这里只搜索评星50以上的镜像:

root@ubuntu:~# docker search --filter=stars=50 ubuntu
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
ubuntu                           Ubuntu is a Debian-based Linux operating sys…   9261                [OK]
dorowu/ubuntu-desktop-lxde-vnc   Docker image to provide HTML5 VNC interface …   274                                     [OK]
rastasheep/ubuntu-sshd           Dockerized SSH service, built on top of offi…   205                                     [OK]
consol/ubuntu-xfce-vnc           Ubuntu container with "headless" VNC session…   157                                     [OK]
ubuntu-upstart                   Upstart is an event-based replacement for th…   96                  [OK]
ansible/ubuntu14.04-ansible      Ubuntu 14.04 LTS with ansible                   96                                      [OK]
neurodebian                      NeuroDebian provides neuroscience research s…   56                  [OK]

下载镜像,这里下载的是最新版本的镜像:

root@ubuntu:~# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
6cf436f81810: Pull complete
987088a85b96: Pull complete
b4624b3efe06: Pull complete
d42beb8ded59: Pull complete
Digest: sha256:7a47ccc3bbe8a451b500d2b53104868b46d60ee8f5b35a24b41a86077c650210
Status: Downloaded newer image for ubuntu:latest

启动容器:

root@ubuntu:/# docker run -it ubuntu bash
root@2d7c5e1c06d8:/#

查看ubuntu镜像的发行版本号:

root@2d7c5e1c06d8:/# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"

执行apt-get update命令更新仓库信息,之后便可以通过apt-get命令安装软件:

root@2d7c5e1c06d8:/# apt-get update
Get:1 http://mirrors.aliyun.com/ubuntu xenial InRelease [247 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease [109 kB]
Get:3 http://mirrors.aliyun.com/ubuntu xenial-security InRelease [109 kB]
Get:4 http://mirrors.aliyun.com/ubuntu xenial/main Sources [1103 kB]
Get:5 http://mirrors.aliyun.com/ubuntu xenial/universe Sources [9802 kB]
Ign:6 https://download.docker.com/linux/ubuntu xenial InRelease
Err:7 https://download.docker.com/linux/ubuntu xenial Release
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: 143.204.15.70 443]
Get:8 http://mirrors.aliyun.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:9 http://mirrors.aliyun.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:10 http://mirrors.aliyun.com/ubuntu xenial-updates/universe Sources [315 kB]
Get:11 http://mirrors.aliyun.com/ubuntu xenial-updates/main Sources [418 kB]
Get:12 http://mirrors.aliyun.com/ubuntu xenial-updates/universe amd64 Packages [951 kB]
Get:13 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 Packages [1189 kB]
Get:14 http://mirrors.aliyun.com/ubuntu xenial-security/universe Sources [126 kB]
Get:15 http://mirrors.aliyun.com/ubuntu xenial-security/main Sources [179 kB]
Get:16 http://mirrors.aliyun.com/ubuntu xenial-security/universe amd64 Packages [544 kB]
Get:17 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 Packages [795 kB]
Reading package lists... Done
W: https://download.docker.com/linux/ubuntu/dists/xenial/InRelease: No system certificates available. Try installing ca-certificates.
W: https://download.docker.com/linux/ubuntu/dists/xenial/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://download.docker.com/linux/ubuntu xenial Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

如果下载速度太慢,可以更新一下软件源。编辑/etc/apt/sources.list,修改为如下内容:

deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

之后再执行命令即可。

安装curl工具:

root@2d7c5e1c06d8:/# apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
.......

 

你可能感兴趣的:(Docker)