alpine镜像容器使用方法

一.最小的镜像alpine(用于替代Ubuntu的服务器版本)

  • 因CentOS8才有kernel4.18版本,alpine3.9版本kernel为4.19,故选择kernel4.14的alpine3.8
  • https://raw.githubusercontent.com/alpinelinux/docker-alpine/dc10be162e9d2c3f799fde73e25ad30f78ff479b/x86_64/Dockerfile
  • https://raw.githubusercontent.com/alpinelinux/docker-alpine/dc10be162e9d2c3f799fde73e25ad30f78ff479b/x86_64/alpine-minirootfs-3.8.4-x86_64.tar.gz

二.构建&运行&使用镜像

  1. 将Dockerfile与alpine-minirootfs-3.8.4-x86_64.tar.gz放在同一文件夹下,执行构建命令:
podman build -t alpine .
  1. 使用镜像运行容器,容器名为alpine001
podman run -itd --name alpine001 localhost/alpine
  1. 进入镜像执行
podman exec -it alpine001 sh

三.alpine内的基础命令

指令 作用
apk 安装软件,类似于yum
连按TAB键两次 输出所有可用的命令,都是基础命令

四.apk命令详解

/ # apk
apk-tools 2.10.1, 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.

apk源配置文件为:/etc/apk/repositories
建议改为阿里源
http://mirrors.aliyun.com/alpine/v3.8/main
http://mirrors.aliyun.com/alpine/v3.8/community

要使用apk安装软件,需要更新缓存,必须先执行

apk update
指令 详解
apk list open 列出符合通配符表达式的软件
apk add openjdk8 安装openjdk8
发布了13 篇原创文章 · 获赞 1 · 访问量 3313

猜你喜欢

转载自blog.csdn.net/q351094752/article/details/103465044
今日推荐