对 Docker 进行构建前需要安装必要的软件。
目前构建镜像有以下两种方式。
- 通过 容器镜像服务 来自动构建。自动推送到阿里云镜像仓库,需要您将构建的 Dockerfile 及相关的上下文(context)上传到 GitHub 或者 Bitbucket 进行构建。同时支持持续集成,即您上传代码到 GitHub 或者 Bitbucket 之后会触发自动构建。
- 您在自己的机器上进行构建,然后推送到阿里云镜像仓库。
在镜像中利用国内软件源加速软件下载和更新
使用已经配置了阿里云镜像软件源的容器镜像
- docker pull registry.cn-hangzhou.aliyuncs.com/acs/ubuntu
- docker pull registry.cn-hangzhou.aliyuncs.com/acs/centos
- docker pull registry.cn-hangzhou.aliyuncs.com/acs/debian
- docker pull registry.cn-hangzhou.aliyuncs.com/acs/alpine
- docker pull registry.cn-hangzhou.aliyuncs.com/acs/node
- docker pull registry.cn-hangzhou.aliyuncs.com/acs/python
- docker pull registry.cn-hangzhou.aliyuncs.com/acs/django
- docker pull registry.cn-hangzhou.aliyuncs.com/acs/ruby
您自行在镜像中配置阿里云镜像软件源
- 访问 阿里云软件源镜像网站。
- 找到您需要的软件源对应的帮助页面,例如 ubuntu 软件源镜像配置帮助页。
- 查看帮助页,学习如何配置软件源镜像信息。
- 在原有容器镜像的基础上添加该软件源配置文件作为 Dockerfile 依赖的上下文(context)文件,通过 Dockerfile 制作新的镜像。
- 通过您本地或者 容器镜像服务 的镜像自动构建机制进行镜像的构建。
- 将镜像推送到阿里云镜像仓库,示例
docker push registry.aliyuncs.com/sample/demo
。
示例:
获取和更新包列表失败
如果您获取和更新包列表(例如 apt-get update
)失败,尝试以下解决方法。
- 使用上面提到的方法采用国内的软件源镜像替换更新国外软件源镜像。
- 跳过更新,继续执行,例如使用命令
sudo apt-get update || true && sudo apt-get install python
。
在文档使用中是否遇到以下问题
更多建议
匿名提交