docker容器学习(二)

Alpine 的意思是“高山的”,比如 Alpine plants高山植物,Alpine skiing高山滑雪、the alpine resort阿尔卑斯山胜地。
Alpine Linux 网站首页注明“Small!Simple!Secure!Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox.”

Alpine 操作系统是一个面向安全的轻型 Linux 发行版。它不同于通常 Linux 发行版,Alpine 采用了 musl libc 和 busybox 以减小系统的体积和运行时资源消耗,但功能上比 busybox 又完善的多,因此得到开源社区越来越多的青睐。
在保持瘦身的同时,Alpine 还提供了自己的包管理工具 apk,可以通过 https://pkgs.alpinelinux.org/packages网站上查询包信息,也可以直接通过 apk 命令直接查询和安装各种软件。

Alpine 由非商业组织维护的,支持广泛场景的 Linux发行版,它特别为资深/重度Linux用户而优化,关注安全,性能和资源效能。Alpine 镜像可以适用于更多常用场景,并且是一个优秀的可以适用于生产的基础系统/环境。

Alpine Docker 镜像也继承了 Alpine Linux 发行版的这些优势。相比于其他 Docker 镜像,它的容量非常小,仅仅只有 5 MB 左右(对比 Ubuntu 系列镜像接近 200 MB),且拥有非常友好的包管理机制。官方镜像来自 docker-alpine 项目。

目前 Docker 官方已开始推荐使用 Alpine 替代之前的 Ubuntu 做为基础镜像环境。这样会带来多个好处。包括镜像下载速度加快,镜像安全性提高,主机之间的切换更方便,占用更少磁盘空间等。

REPOSITORYTAGIMAGE IDVIRTUAL SIZE
alpinelatest4e38e38c8ce04.799 MB
adebianlatest4d6ce913b13084.98 MB
aubuntulatestb39b81afc8ca188.3 MB
acentoslatest8efe422e6104210 MB
一、获取并使用官方镜像

由于镜像很小,下载时间往往很短;目前,大部分 Docker 官方镜像都已经支持 Alpine 作为基础镜像,可以很容易进行迁移。
例如:
ubuntu/debian -> alpine
python:2.7 -> python:2.7-alpine
ruby:2.3 -> ruby:2.3-alpine
另外,如果使用 Alpine 镜像替换 Ubuntu 基础镜像,安装软件包时需要用 apk 包管理器替换 apt 工具。

二、更新国内软件包源

# Alpine的源文件为:/etc/apk/repositories,
# 默认的源地址为:http://dl-cdn.alpinelinux.org/
#采用国内阿里云的源,文件内容为:
https://mirrors.aliyun.com/alpine/v3.6/main/https://mirrors.aliyun.com/alpine/v3.6/community/
# 如果采用中国科技大学的源,文件内容为:
https://mirrors.ustc.edu.cn/alpine/v3.6/main/https://mirrors.ustc.edu.cn/alpine/v3.6/community/

三、apk命令详解
# apk -h
apk-tools 2.10.0, compiled for x86_64.
Installing and removing packages:
add Add PACKAGEs to 'world' and install (or upgrade) them, while ensuring that all dependencies are met
del   Remove PACKAGEs from 'world' and uninstall them

System maintenance:
  fix   Repair package or upgrade it without modifying main dependencies
  update Update repository indexes from all remote repositories
  upgrade Upgrade currently installed packages to match repositories
  cache  Download missing PACKAGEs to cache and/or delete unneeded files from cache

Querying information about packages:
  info    Give detailed information about PACKAGEs or repositories
  list    List packages by PATTERN and other criteria
  dot     Generate graphviz graphs
  policy  Show repository policy for packages

Repository maintenance:
  index   Create repository index file from FILEs
  fetch   Download PACKAGEs from global repositories to a local directory
  verify  Verify package integrity and signature
  manifest  Show checksums of package contents
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

腹黑的乌鸡

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值