使用Podman在IBM云上的OpenShift中部署构建的容器镜像〜容器镜像推送版〜
首先
以下是介绍的步骤。
-
- 使用Podman构建Dockerfile
- 将其推送到IBM Cloud容器注册表
环境
macOS Monterey 12.0.1
IBM Cloud CLI(请参考此处安装方法。)
OpenShift CLI(请参考此处安装方法。)
首先在本地进行确认。
因为我想在CentOS + nginx环境中尝试,所以首先在适当的目录下创建Dockerfile和index.html文件。
FROM centos:latest
RUN yum install -y nginx
COPY index.html /usr/share/nginx/html/
CMD ["nginx","-g","deamon off;"]
CMD nginx -g "daemon off;"
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Podman Demo</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
一旦创建完成后,我们将其移动到与Dockerfile相同的层级并立即使用Podman进行构建尝试。
$ podman build -t centos/nginx:latest .
・
・
・
Successfully tagged localhost/centos/nginx:latest
3a059818de62761f7863ed7c1f2d97257f66f7d6e555f325bebaa8a657775a28
我们来试试看吧。
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/centos/nginx latest 3a059818de62 14 minutes ago 327 MB
$ podman run -d -p 8080:80 localhost/centos/nginx
88c15afc022a3660337b1cdeccbaed8a4c0c2282091a7d24b990bb813af60f48
$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
88c15afc022a localhost/centos/nginx:latest /bin/sh -c nginx ... 7 seconds ago Up 7 seconds ago 0.0.0.0:8080->80/tcp relaxed_nobel

听起来没问题。已经在本地确认过了,所以我会停止了。
$ podman stop 88c15afc022a
$ podman rm 88c15afc022a
让我们将容器镜像推送到IBM Cloud中。






使用先前创建的API密钥,在Podman中登录到容器注册表(jp.icr.io/podman-centos-nginx)。
在用户名字段中输入iamapikey,在密码字段中输入先前记录的API密钥。
$ podman login jp.icr.io/podman-centos-nginx
Username: iamapikey
Password: # APIキー
Login Succeeded!
既然能够登录成功,现在我们来给它打上标签并推送吧。
podman tag localhost/centos/nginx jp.icr.io/{名前空間名}/{リポジトリー名}
podman push jp.icr.io/{名前空間名}/{リポジトリー名} # 少し時間がかかります
如果可以推送,就检查容器注册表。

非常棒呢。
我們將在下一篇文章中進行對OpenShift的部署。
撰写文章中…