Ubuntu执行sudo apt-get update报错E: Failed to fetch https://mirrors.aliyun.com/docker-ce/linux/ubuntu/di

Ubuntu执行sudo apt-get update报错E: Failed to fetch https://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/xenial/InRelease Unable to find expected entry ‘stable/source/Sources’ in Release file (Wrong sources.list entry or malformed file)

报错内容:

E: Failed to fetch https://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/xenial/InRelease  Unable to find expected entry 'stable/source/Sources' in Release file (Wrong sources.list entry or malformed file)
W: Failed to fetch https://pkg.jenkins.io/debian-stable/binary/InRelease  Could not resolve host: pkg.jenkins.io
W: Some index files failed to download. They have been ignored, or old ones used instead.

报错原因:

# 这个错误可能是由于源列表文件(/etc/apt/sources.list)中的条目不正确或文件格式不正确。
# 可以尝试使用以下命令备份源列表文件并创建一个新的源列表文件:

解决办法:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nano /etc/apt/sources.list

# 在编辑器中打开源列表文件后,将内容替换为以下内容(适用于 Ubuntu 16.04,根据版本自查源地址):

# 阿里云镜像源:

  deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
  deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
  deb https://pkg.jenkins.io/debian-stable binary/

# 清华大学镜像源:
  deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
  deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
  deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
  deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
  deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
  deb https://pkg.jenkins.io/debian-stable binary/

# 将其中之一添加到 `/etc/apt/sources.list` 文件中,
# 保存后运行 `sudo apt-get clean' 'sudo apt-get update` 命令,应该可以成功更新索引文件

sudo apt-get clean

sudo apt-get update

补充:

如果还是没有办法解决问题,请按照下面步骤操作一遍

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get clean

sudo apt-get update

你可能感兴趣的:(Linux,ubuntu,linux)