Docker 更新镜像

docker镜像如下:

今天在运行的容器内使用 apt-get update 命令进行更新时,发下很多404错误。

 1 Err http://archive.ubuntu.com wily-updates/restricted amd64 Packages
 2   404  Not Found [IP: 91.189.88.152 80]
 3 Err http://archive.ubuntu.com wily-updates/universe amd64 Packages
 4   404  Not Found [IP: 91.189.88.152 80]
 5 Err http://archive.ubuntu.com wily-security/main Sources
 6   404  Not Found [IP: 91.189.88.152 80]
 7 Err http://archive.ubuntu.com wily-security/restricted Sources
 8   404  Not Found [IP: 91.189.88.152 80]
 9 Err http://archive.ubuntu.com wily-security/universe Sources
10   404  Not Found [IP: 91.189.88.152 80]
11 Err http://archive.ubuntu.com wily-security/main amd64 Packages
12   404  Not Found [IP: 91.189.88.152 80]
13 Err http://archive.ubuntu.com wily-security/restricted amd64 Packages
14   404  Not Found [IP: 91.189.88.152 80]
15 Err http://archive.ubuntu.com wily-security/universe amd64 Packages
16   404  Not Found [IP: 91.189.88.152 80]
17 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/wily/main/source/Sources  404  Not Found [IP: 91.189.88.152 80]
18 
19 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/wily/restricted/source/Sources  404  Not Found [IP: 91.189.88.152 80]
20 
21 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/wily/universe/source/Sources  404  Not Found [IP: 91.189.88.152 80]
22 
23 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/wily/main/binary-amd64/Packages  404  Not Found [IP: 91.189.88.152 80]
24 
25 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/wily/restricted/binary-amd64/Packages  404  Not Found [IP: 91.189.88.152 80]
26 
27 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/wily/universe/binary-amd64/Packages  404  Not Found [IP: 91.189.88.152 80]
28 
29 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/wily-updates/main/source/Sources  404  Not Found [IP: 91.189.88.152 80]
30 
31 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/wily-updates/restricted/source/Sources  404  Not Found [IP: 91.189.88.152 80]

经查,每一个Ubuntu发布版本都有它的结束时间,通常,Ubuntu发布版本支持18个月,而LTS (Long Term Support)(长期支持)版本分别支持3年(服务器版)和5年(桌面版)。

当一个Ubuntu发布版本到达结束期后,它的库将不再能够访问,并且你也不会得到任何维护更新和安全补丁。当写这个的时候,我的15.10版本已经到了它的结束期了。
对于那些使用旧版本的Ubuntu的用户,这是一个过期库的归档。因此,Ubuntu过期后,我们必须把源切换到 old-releases.ubuntu.com。

下面的方法通过切换到旧版本的源来解决“404 Not Found”错误。

首先,使用旧版本的源来替换当前主源

$ sudo sed -i -r 's/([a-z]{2}\.)?archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
$ sudo sed -i -r 's/security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

现在,应该能够在旧版本的Ubuntu镜像系统上进行安装或者更新了

在完成操作之后,输入 exit命令来退出这个容器。

此时ID为5a76c9bb0d02的容器,是按我们的需求更改的容器。我们可以通过命令 docker commit来提交容器副本。

sudo docker commit -m="has update" -a="zpt" 5a76c9bb0d02 zpt/ubuntu:v2

各个参数说明:

  • -m:提交的描述信息

  • -a:指定镜像作者

  • 5a76c9bb0d02:容器ID

  • runoob/ubuntu:v2:指定要创建的目标镜像名

接下来我们可以使用 docker images 命令来查看我们的新镜像 zpt/ubuntu:v2

 

posted @ 2018-10-30 17:48  周伯通之草堂  阅读(23932)  评论(1编辑  收藏  举报