我在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來解決這個問題。 –