我已经安装"Development Tools"
并运行以下命令:
podman pull mysql:latest # this is pulled from docker.io
podman images # lists the correct image
mkdir ~/mysql_data ; cd mysql_data
podman run -d \
--name mysql \
-p 3306:3306 \
-v ~/mysql_data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD='My password' \
-e MYSQL_USER=dbuser \
-e MYSQL_PASSWORD='My DB password' \
-e MYSQL_DATABASE=testdb \
mysql:latest
podman ps # lists no running containers
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
341ff9ebe686 docker.io/library/mysql:latest mysqld 7 minutes ago Created 0.0.0.0:3306->3306/tcp mysql
但是,当我尝试执行下一个命令(podman exec -it mysql /bin/bash
)时,出现以下错误:
Error: can only create exec sessions on running containers: container state improper
我究竟做错了什么?
谢谢。
答案1
显然,SELinux 不喜欢主文件夹中的容器,因此技巧是将 a 添加:Z
到卷中,如下所示:
-v ~/mysql_data:/var/lib/mysql:Z