当前位置 > it书童 > docker > 正文

docker ubuntu 镜像替换阿里云源

docker it书童 2019-10-04 17:42:20 0赞 0踩 2795阅读 0评论

在 Dockerfile 中添加:

# 替换源
COPY ./sources.list /etc/apt/sources.list

sources.list 内容

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

由于 Dockfile 引入的文件不能超出其所在目录,因为每个 Dockfile 所在目录,如果需要换源,就必须复制一份 sources.list,这个操作有点繁琐

关于我
一个文科出身的程序员,追求做个有趣的人,传播有价值的知识,微信公众号主要分享读书思考心得,不会有代码类文章,非程序员的同学请放心订阅
转载须注明出处:https://www.itshutong.com/articles/199/replace-alicloud-source-with-docker-ubuntu-image