使用podman-compose快速部署应用

我们对于docker-compose并不陌生,它是一个用于编排多个可能相互依赖的容器的工具。

而Podman Compose项目的目标是作为 docker-ompose 的替代品,而不需要对 docker-compose.yaml 文件进行任何修改。

要想使用podman-compose需要先安装podman,然后安装podman-compose。

Rocky8下安装podman:

yum install -y podman

Rocky8下安装podman-compose,因为podman-compose是基于python开发,可以使用pip来安装:

pip3 install podman-compose

 

示例:使用podman-compose部署wordpress

编辑docker-compose.yml文件,内容如下

version: "3.8"services:web:image: wordpressrestart: alwaysvolumes:- wordpress:/var/www/htmlports:- 8080:80environment:WORDPRESS_DB_HOST: dbWORDPRESS_DB_USER: magazineWORDPRESS_DB_NAME: magazineWORDPRESS_DB_PASSWORD: 1maGazine!WORDPRESS_TABLE_PREFIX: czWORDPRESS_DEBUG: 0depends_on:- dbnetworks:- wpnetdb:image: mariadb:10.5restart: alwaysports:- 6603:3306
volumes:- wpdbvol:/var/lib/mysql
environment:MYSQL_DATABASE: magazineMYSQL_USER: magazineMYSQL_PASSWORD: 1maGazine!MYSQL_ROOT_PASSWORD: 1maGazine!networks:- wpnetvolumes:wordpress: {}wpdbvol: {}
networks:wpnet: {}

为了让podman拉取镜像更快,先给它配置个加速器

# mv /etc/containers/registries.conf /etc/containers/registries.conf.bak# vi /etc/containers/registries.conf ##添加如下内容unqualified-search-registries = ["docker.io"]
[[registry]]prefix = "docker.io"location = "docker.io"
[[registry.mirror]]location = "hub-mirror.c.163.com"
[[registry.mirror]]location = "mirror.baidubce.com"
[[registry.mirror]]location = "f1361db2.m.daocloud.io"
[[registry.mirror]]location = "ustc-edu-cn.mirror.aliyuncs.com"
[[registry.mirror]]location = "ghcr.io"

然后就可以启动wordpress容器啦:

# podman-compose up -d

用起来其实跟docker-compose一样。

posted @ 2023-05-22 15:21  Linux运维阿铭  阅读(292)  评论(0编辑  收藏  举报