docker中apt-get update出现问题

使用官方镜像php:5.6-fpm,修改/etc/apt/sources.list文件的源后apt-get update提示如下:
image.png
使用的源为:

deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib

补充下面的错误信息:

Reading package lists... Done
W: The repository 'http://mirrors.aliyun.com/debian stretch Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://mirrors.aliyun.com/debian-security stretch/updates Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://mirrors.aliyun.com/debian stretch-updates Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://mirrors.aliyun.com/debian/dists/stretch/main/source/Sources  SECURITY: URL redirect target contains control characters, rejecting. [IP: 117.21.230.243 80]
E: Failed to fetch http://mirrors.aliyun.com/debian-security/dists/stretch/updates/main/source/Sources  SECURITY: URL redirect target contains control characters, rejecting. [IP: 117.21.230.243 80]
E: Failed to fetch http://mirrors.aliyun.com/debian/dists/stretch-updates/contrib/source/Sources  SECURITY: URL redirect target contains control characters, rejecting. [IP: 117.21.230.243 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
阅读 3.6k
1 个回答

Debian stretch (Debian 9) 已经撤掉了这些Component,因为已经是oldstable了,所以并没有这么多Component可供使用,你直接照抄肯定出错。

在docker中不要照抄那些仓库,很多docker镜像用的并不一定是最新版本的Debian/Ubuntu,不能保证这么多的Component可以使用,因此你要使用国内镜像的话应该替换掉/etc/apt/sources.list中官方仓库地址即可,参考命令:

sed -i 's/deb.debian.org/mirrors.aliyun.com/;s/security.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list

重新运行一个新的容器执行上面的命令替换镜像仓库即可。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题