podman使用记录

1.查看镜像

podman images

 

 

2.查看已运行容器

podman ps

 

 3.运行容器

podman run -itd --name redis-test -p 6379:6379 f1b6973564e9

 

说明: -p 6379:6379:映射容器服务的 6379 端口(左)到宿主机的 6379 端口(右),外部可以直接通过宿主机ip:6379 (左)访问到 Redis 的服务。

4.开始/停止/重启 容器名

podman start/stop/restart  name

5.开机自启动设置

①将podman-container1.service  拷贝到下面路径
/usr/lib/systemd/system
②执行下面命令:
systemctl enable podman-container1.service

③由于之前安装过pg数据库和redis,可能有冲突,不能自启动,需要重启容器
podman restart 容器名

 

podman-container1.service文件内容

###podman-container1.service###
[Unit]
Description=Podman container1

[Service]
Type=simple
ExecStart=/usr/bin/podman start -a myredis2
ExecStop=/usr/bin/podman stop -t 10 myredis2

[Install]
WantedBy=multi-user.target

 

posted @ 2022-03-18 12:05  当年小清新  阅读(208)  评论(0编辑  收藏  举报