我在docker上安装了Ubuntu 14.04镜像。镜像自带Ubuntu官方软件源。由于我在中国,无法连接这些服务器?我必须编辑etc/apt/source.list以使用替换软件源vi 或 vim。然而,这两个编辑器中的任何一个都没有附带 Ubuntu 映像。如果我尝试安装编辑器,那么我必须更改软件源。我怎么解决这个问题?
小智 5
您可以创建一个派生的 docker 镜像,如下所示:
Dockerfile
FROM ubuntu:14.04
COPY ./sources.list /etc/apt/
Run Code Online (Sandbox Code Playgroud)
sources.list (我以前在中国用过这些,效果很好,换成你喜欢的)
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty universe
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu trusty partner
# deb-src http://archive.canonical.com/ubuntu trusty partner
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
#deb http://extras.ubuntu.com/ubuntu trusty main
#deb-src http://extras.ubuntu.com/ubuntu trusty main
Run Code Online (Sandbox Code Playgroud)
创建这些文件后,您可以通过运行例如:
docker build --tag ubuntu:14.04-cn
Run Code Online (Sandbox Code Playgroud)
并在您的项目中使用它,如果您需要将其上传到 docker hub,则需要相应地更改名称。
此外,我建议你直接在你的镜像中安装你需要的软件,这样你就不必每次启动容器时都安装依赖项,也因为无论如何你都是在构建你的镜像。
| 归档时间: |
|
| 查看次数: |
2034 次 |
| 最近记录: |