阅读807 返回首页    go 阿里云


常用 Docker 相关软件下载加速__构建管理_用户指南_容器服务-阿里云

对 Docker 进行构建前需要安装必要的软件。

目前构建镜像有以下两种方式。

  • 通过 Docker Hub 来自动构建。自动推送到阿里云镜像仓库,需要您将构建的 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

您自行在镜像中配置阿里云镜像软件源

操作流程

  1. 访问 阿里云软件源镜像网站

  2. 找到您需要的软件源对应的帮助页面,例如 ubuntu 软件源镜像配置帮助页

  3. 查看帮助页,学习如何配置软件源镜像信息。

  4. 在原有容器镜像的基础上添加该软件源配置文件作为 Dockerfile 依赖的上下文(context)文件,通过 Dockerfile 制作新的镜像。

  5. 通过您本地或者 Docker Hub 的镜像自动构建机制进行镜像的构建。

  6. 将镜像推送到阿里云镜像仓库,示例 docker push registry.aliyuncs.com/sample/demo

示例:

  • ubuntu:12.04,14:04 GitHub 地址

    ubuntu:14:04 Dockerfile

    1. FROM ubuntu:14.04
    2. MAINTAINER Li Yi <denverdino@gmail.com>
    3. RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/' /etc/apt/sources.list
  • centos:6, centos:7 GitHub 地址

  • nodejs:4.2, nodejs:5.3 GitHub 地址
  • pyhton:2.5, python:3.5 GitHub 地址

获取和更新包列表失败

如果您获取和更新包列表(例如 apt-get update)失败,尝试以下解决方法。

  • 使用上面提到的方法采用国内的软件源镜像替换更新国外软件源镜像。
  • 跳过更新,继续执行,例如使用命令 sudo apt-get update || true && sudo apt-get install python

最后更新:2016-11-23 16:03:52

  上一篇:go Dockerfile 支持的指令__构建管理_用户指南_容器服务-阿里云
  下一篇:go 基于容器 HUB 的持续交付__DevOps_用户指南_容器服务-阿里云