diff --git a/cases/os/alpine.md b/cases/os/alpine.md index 38cf5c3..b9d76d0 100644 --- a/cases/os/alpine.md +++ b/cases/os/alpine.md @@ -14,7 +14,7 @@ 下表是官方镜像的大小比较: -```sh +```bash REPOSITORY TAG IMAGE ID VIRTUAL SIZE alpine latest 4e38e38c8ce0 4.799 MB debian latest 4d6ce913b130 84.98 MB @@ -26,21 +26,11 @@ centos latest 8efe422e6104 210 MB 由于镜像很小,下载时间往往很短,读者可以直接使用 `docker run` 指令直接运行一个 `Alpine` 容器,并指定运行的 Linux 指令,例如: -```sh +```bash $ docker run alpine echo '123' 123 ``` -笔者使用 time 工具来测试下在本地没有提前 pull 镜像情况下,执行 echo 命令的时间,仅需要 3 秒左右。 - -```sh -$ time docker run alpine echo '123'Unable to find image 'alpine:latest' locallylatest: Pulling from library/alpine - -e110a4a17941: Pull completeDigest: sha256:3dcdb92d7432d56604d4545cbd324b14e647b313626d99b889d0626de158f73aStatus: Downloaded newer image for alpine:latest123 - -real 0m3.367s user 0m0.040s sys 0m0.007s -``` - ### 迁移至 `Alpine` 基础镜像 目前,大部分 Docker 官方镜像都已经支持 Alpine 作为基础镜像,可以很容易进行迁移。 @@ -53,20 +43,20 @@ real 0m3.367s user 0m0.040s sys 0m0.007s 另外,如果使用 `Alpine` 镜像替换 `Ubuntu` 基础镜像,安装软件包时需要用 apk 包管理器替换 apt 工具,如 -```sh +```bash $ apk add --no-cache ``` `Alpine` 中软件安装包的名字可能会与其他发行版有所不同,可以在 `https://pkgs.alpinelinux.org/packages` 网站搜索并确定安装包名称。如果需要的安装包不在主索引内,但是在测试或社区索引中。那么可以按照以下方法使用这些安装包。 -```sh +```bash $ echo "http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories $ apk --update add --no-cache ``` ### 相关资源 -* `Apline` 官网:http://alpinelinux.org/ -* `Apline` 官方仓库:https://github.com/alpinelinux -* `Apline` 官方镜像:https://hub.docker.com/_/alpine/ -* `Apline` 官方镜像仓库:https://github.com/gliderlabs/docker-alpine +* `Alpine` 官网:http://alpinelinux.org/ +* `Alpine` 官方仓库:https://github.com/alpinelinux +* `Alpine` 官方镜像:https://hub.docker.com/_/alpine/ +* `Alpine` 官方镜像仓库:https://github.com/gliderlabs/docker-alpine diff --git a/cases/os/busybox.md b/cases/os/busybox.md index d9d24d6..6364dce 100644 --- a/cases/os/busybox.md +++ b/cases/os/busybox.md @@ -12,7 +12,7 @@ BusyBox 可运行于多款 POSIX 环境的操作系统中,如 Linux(包括 A 在 Docker Hub 中搜索 busybox 相关的镜像。 -```sh +```bash $ docker search busybox NAME DESCRIPTION STARS OFFICIAL AUTOMATED busybox Busybox base image. 755 [OK] @@ -26,7 +26,7 @@ azukiapp/busybox This image is meant to be used as the base... 读者可以看到最受欢迎的镜像同时带有 OFFICIAL 标记,说明它是官方镜像。用户使用 docker pull 指令下载镜像 `busybox:latest`: -```sh +```bash $ docker pull busybox:latest busybox:latest: The image you are pulling has been verified e433a6c5b276: Pull complete @@ -38,7 +38,7 @@ Status: Downloaded newer image for busybox:latest 下载后,可以看到 busybox 镜像只有2.433 MB: -```sh +```bash $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE busybox latest e72ac664f4f0 6 weeks ago 2.433 MB @@ -48,7 +48,7 @@ busybox latest e72ac664f4f0 6 weeks ago 启动一个 busybox 容器,并在容器中执行 grep 命令。 -```sh +```bash $ docker run -it busybox / # grep BusyBox v1.22.1 (2014-05-22 23:22:11 UTC) multi-call binary. @@ -83,7 +83,7 @@ Search for PATTERN in FILEs (or stdin) 查看容器内的挂载信息。 -```sh +```bash / # mount rootfs on / type rootfs (rw) none on / type aufs (rw,relatime,si=b455817946f8505c)