mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-28 20:55:21 +00:00
Remove blank lines after code block markers
This commit is contained in:
@@ -24,14 +24,12 @@ Buildah 由 Red Hat 主导开发,通常和 Podman、Skopeo 一起使用,被
|
||||
```bash
|
||||
$ sudo dnf install -y buildah
|
||||
```
|
||||
|
||||
以 Ubuntu/Debian 为例(需引入官方源后):
|
||||
|
||||
```bash
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get -y install buildah
|
||||
```
|
||||
|
||||
### 基础用法示例
|
||||
|
||||
#### 1. 从现有的 Dockerfile 构建镜像
|
||||
@@ -41,7 +39,6 @@ Buildah 最常见的用法就是像 Docker 一样根据 `Dockerfile` 来构建
|
||||
```bash
|
||||
$ buildah bud -t my-app:latest .
|
||||
```
|
||||
|
||||
可以看到在这点上,它与 `docker build` 的体验完全一致。
|
||||
|
||||
#### 2. 交互式从空镜像开始构建
|
||||
@@ -49,7 +46,6 @@ $ buildah bud -t my-app:latest .
|
||||
除了使用 Dockerfile,Buildah 最强大的功能来自于它的交互式和脚本化构建机制。我们可以从一个极简的镜像(或基础镜像)开始构建:
|
||||
|
||||
```bash
|
||||
|
||||
# 获取一个基础镜像
|
||||
$ container=$(buildah from alpine:latest)
|
||||
|
||||
@@ -71,7 +67,6 @@ $ buildah commit $container my-hello-image:latest
|
||||
$ buildah unmount $container
|
||||
$ buildah rm $container
|
||||
```
|
||||
|
||||
这种模式在自动化流水线中极为有用,因为我们可以将上述过程编写成标准的 bash 脚本,无需为了构建镜像而撰写只在其独立语法中运行的 Dockerfile 指令。
|
||||
|
||||
#### 3. 查看和推送镜像
|
||||
@@ -79,12 +74,10 @@ $ buildah rm $container
|
||||
通过 `buildah images` 可以查看当前环境中的镜像。推送镜像到外部 Registry 也十分安全方便:
|
||||
|
||||
```bash
|
||||
|
||||
# 查看本地构建的镜像
|
||||
$ buildah images
|
||||
|
||||
# 推送镜像到 Docker Hub(注意需要先登录)
|
||||
$ buildah push my-hello-image:latest docker://docker.io/username/my-hello-image:latest
|
||||
```
|
||||
|
||||
结合其无需特权和灵活脚本的优点,Buildah 正变得越来越受到构建和分发 OCI 镜像的用户喜爱。
|
||||
|
||||
Reference in New Issue
Block a user