我在docker上安装了Ubuntu 14.04镜像。该镜像带有Ubuntu官方软件源码。由于我在中国,无法连接到这些服务器,因此我必须编辑etc/apt/source.list用vi或vim替换软件源。但是,Ubuntu映像不会与两个编辑器中的任何一个一起提供。如果我尝试 来安装编辑器,那么我必须更改软件源。我怎么解决这个问题?无法替换docker中的软件源码Ubuntu镜像
1
A
回答
1
如下您可以创建一个派生泊坞窗图像:
Dockerfile
FROM ubuntu:14.04
COPY ./sources.list /etc/apt/
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
创建这些文件后,您可以通过运行来构建映像,例如:
docker build --tag ubuntu:14.04-cn
并在您的项目中使用它,如果您需要将其上传到码头集线器,则需要相应地更改名称。
此外,我建议您直接在图像中安装所需的软件,这样您不必在每次启动容器时都安装依赖项,因为无论如何您都在构建图像。
+0
感谢您提供详细的重播和有用的建议。我是初学者,所以我需要摸索很多东西。 –
+0
如果答案正确解决了您的问题,请将其标记为正确,以便其他人可以在将来遵循同一个系统。如果没有让我知道,如果有什么东西不能正常工作,我可以修改它。 – oirad
相关问题
- 1. 无法在Docker中安装软件包Ubuntu镜像
- 2. 无法在Docker镜像中安装R软件包
- 3. 无法在Azure上的Ubuntu 16.04上连接Percona Docker镜像
- 4. 无法连接到docker docker镜像中的守护进程docker
- 5. 来自docker的卷曲ubuntu镜像
- 6. 如何访问Docker镜像中的JIRA软件文件?
- 7. Docker使用Docker文件创建镜像“Ubuntu 14.04”
- 8. 通过Dockerfile构建docker ubuntu镜像
- 9. 无法连接到mysql docker镜像
- 10. Ubuntu 14.04上可以使用Ubuntu 14.04的Docker镜像吗?
- 11. Docker镜像中的IDE?
- 12. 无法让Jenkins Docker从机构建Docker镜像
- 13. 无法将Docker镜像推送到Openshift Origin Docker注册表
- 14. 在Jenkins中构建Docker镜像(在Docker镜像中) - Cloud Docker代理
- 15. 如何在我的ubuntu docker镜像中安装“ifconfig”命令?
- 16. 将Docker镜像转换为Google Compute Engine镜像
- 17. Docker镜像格式
- 18. Docker镜像位置
- 19. 如何在Docker镜像中打开Ubuntu GUI
- 20. 如何调查Ubuntu的两个Docker镜像之间的差异?
- 21. 无法在Docker镜像中配置区域设置
- 22. Python无法在Docker镜像中找到sqlalchemy-migrate
- 23. Ansible无法从aws ecr(注册表)中拖出docker镜像
- 24. Xcode无法找到软件镜像来安装此版本
- 25. Docker镜像的内容
- 26. 缓存的Docker镜像?
- 27. 不同主机中的Selenium节点/ chrome docker镜像和selenium/hub docker镜像
- 28. 基于Alpine的Docker镜像在Ubuntu主机上完全兼容?
- 29. 基于Ubuntu的Docker镜像可以运行在Redhat上吗?
- 30. 如何更改Docker镜像中的Ruby版本(用2.0.0替换2.2.0)
从基础图像创建派生图像,并在该脚本中使用sed更改源代码 –
感谢您的回复,但我不知道如何使用sed。我用dockerfile来解决这个问题。 –