第八章 Docker与Alpine不解之缘

2018-11-26  本文已影响0人  箫起秦楼
alpine.jpg

Alpine简介

REPOSITORY          TAG           IMAGE ID          VIRTUAL SIZE
alpine              latest        4e38e38c8ce0      4.799 MB
debian              latest        4d6ce913b130      84.98 MB
ubuntu              latest        b39b81afc8ca      188.3 MB
centos              latest        8efe422e6104      210 MB

获取并使用官方镜像:

[root@centos_7_1]:[~]# docker image pull alpine:3.8
3.8: Pulling from library/alpine
4fe2ade4980c: Pull complete
Digest: sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528
Status: Downloaded newer image for alpine:3.8
#-----------------------------分割线-----------------------------
[root@centos_7_1]:[~]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@centos_7_1]:[~]# docker container run --name a1 -it alpine:3.8
/ #
/ # ls /
bin    dev    etc    home   lib    media  mnt    proc   root   run    sbin   srv    sys    tmp    usr    var
/ #

迁移至 Alpine 基础镜像

ubuntu/debian -> alpine
python:2.7 -> python:2.7-alpine
ruby:2.3 -> ruby:2.3-alpine

另外,如果使用 Alpine 镜像替换 Ubuntu 基础镜像,安装软件包时需要用 apk 包管理器替换 apt 工具,如

$ apk add --no-cache <package>
$ echo "http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
$ apk --update add --no-cache <package>

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

Use apk <command> --help for command-specific help.
Use apk --help --verbose for a full command listing.

This apk has coffee making abilities.

| :----- | :-----: |
| 第一章 初识Docker | 点击此处 |
| 第二章 安装Docker以及简单配置 | 点击此处 |
| 第三章 Docker容器的生命周期 | 点击此处 |
| 第四章 Docker命令汇总 | 点击此处 |
| 第五章 Docker基础命令详解 | 点击此处 |
| 第六章 Docker---镜像的命令详解 | 点击此处 |
| 第七章 Docker---容器的命令详解 | 点击此处 |
| 第八章 Docker与Alpine不解之缘 | 点击此处 |
|未完待续| |

上一篇 下一篇

猜你喜欢

热点阅读