我在尝试使用Podman在RedHat 8上运行OpenMapTilesServer时遇到问题。
这是我的开始脚本:
sudo podman run -d -v $(pwd):/data -p 8080:80 docker.io/klokantech/openmaptiles-server
图像显示正常,并且似乎开始正常。 我可以执行
podman ps
并查看容器。一切看起来还好。如果我使用
查看日志podman logs <containerID>
我看不到任何我认为有问题的东西,但是当我尝试访问主页时 http://localhost:8080,然后出现找不到网站错误。
我认为这可能是防火墙问题,因此我禁用了防火墙,但结果相同。我还通过安装Tomcat并启动它以提供几个HTML页面的服务来确认。所有这一切都没有错误。
有人可以建议我做一些进一步的调试来做到这一点吗?谢谢...
答案 0 :(得分:1)
我启动了一个CentOS 8 VM进行测试,然后从您的帖子中运行podman
命令会导致失败。今天早上我花了一点时间来弄清楚发生了什么。
看podman run
的输出,我看到以下错误:
[root@localhost data]# podman run --name tiles -v /tmp/data:/data -p 8080:80 docker.io/klokantech/openmaptiles-server
[...]
2019-11-05 12:29:26,812 INFO exited: wizard (exit status 1; not expected)
如果我podman exec
进入容器,则可以手动运行wizard
命令并查看更详细的日志。首先,我们需要弄清楚wizard
命令的位置。由于容器使用supervisord
作为流程主管,所以这意味着我们可能需要查看/etc/supervisor
以获得详细信息:
[root@localhost ~]# podman exec -it tiles bash
root@de362646e453:/etc/supervisor# cd /etc/supervisor/
root@de362646e453:/etc/supervisor# ls
conf.d supervisord.conf
root@de362646e453:/etc/supervisor# cd conf.d/
root@de362646e453:/etc/supervisor/conf.d# ls
openmaptiles.conf
root@de362646e453:/etc/supervisor/conf.d# cat openmaptiles.conf
[program:wizard]
command=/bin/bash -c "cd /usr/local/src && node wizard"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
autostart=true
autorestart=false
startsecs=0
关键信息是command
文件中的openmaptiles.conf
行。让我们尝试手动运行相同的命令:
root@de362646e453:/# cd /usr/local/src/
root@de362646e453:/usr/local/src# node wizard
Starting OpenMapTiles Map Server (action: run)
fs.js:961
return binding.readdir(pathModule._makeLong(path), options.encoding);
^
Error: EACCES: permission denied, scandir '/data'
at Error (native)
at Object.fs.readdirSync (fs.js:961:18)
at Wizard.init (/usr/local/src/wizard/src/main.js:928:19)
at new Wizard (/usr/local/src/wizard/src/main.js:119:8)
at Object.<anonymous> (/usr/local/src/wizard/src/main.js:1270:1)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
我们在/data
目录中收到“权限被拒绝”错误。权限看起来还可以:
root@de362646e453:/# ls -ld /data
drwxr-xr-x. 2 root root 6 Nov 5 12:08 /data
但是我们无法访问它:
root@de362646e453:/# cd /data
root@de362646e453:/data# ls
ls: cannot open directory '.': Permission denied
如果文件许可权还不错,但您仍然无法访问某些内容,则通常意味着该看一下selinux配置了。 RHEL(和CentOS)都默认启用了selinux。这样可以防止容器访问文件系统中尚未明确授予其访问权限的部分。
首先,在主机上,验证selinux
是否以enforcing
模式运行:
[root@localhost ~]# getenforce
Enforcing
是(按预期)。让我们将其置于宽松模式下,看看是否能解决我们的问题:
[root@localhost ~]# setenforce 0
现在,在容器内,让我们尝试再次访问/data
目录:
[root@localhost ~]# podman exec -it tiles bash
root@de362646e453:/# ls /data
root@de362646e453:/#
太好了!没有更多的错误。让我们尝试重新启动容器:
[root@localhost data]# podman run --name tiles -v $(pwd):/data -p 8080:80 docker.io/klokantech/openmaptiles-server
/usr/lib/python2.7/dist-packages/supervisor/options.py:298: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
2019-11-05 12:37:18,493 CRIT Supervisor running as root (no user in config file)
2019-11-05 12:37:18,493 INFO Included extra file "/etc/supervisor/conf.d/openmaptiles.conf" during parsing
2019-11-05 12:37:18,498 INFO Creating socket tcp://localhost:8081
2019-11-05 12:37:18,500 INFO Closing socket tcp://localhost:8081
2019-11-05 12:37:18,510 INFO RPC interface 'supervisor' initialized
2019-11-05 12:37:18,511 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2019-11-05 12:37:18,511 INFO supervisord started with pid 1
2019-11-05 12:37:19,514 INFO spawned: 'wizard' with pid 8
2019-11-05 12:37:19,516 INFO spawned: 'xvfb' with pid 9
Starting OpenMapTiles Map Server (action: run)
2019-11-05 12:37:19,954 INFO success: wizard entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2019-11-05 12:37:19,954 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Config file not found!
Starting installation...
Installation wizard started at http://:::80/
List of available downloads ready.
这看起来像是一次成功的启动,实际上,我现在可以在主机端口8080
上访问tile服务器。
现在我们要做出决定:
我通常会建议(2),但是CentOS 8中的默认selinux策略看起来有些愚蠢的默认值使处理过程变得更加困难(禁用了可识别问题的审核日志消息),所以让我们继续( 1):
编辑/etc/selinux/config
。
将SELINUX=enforcing
更改为SELINUX=permissive
(允许访问,但selinux仍处于活动状态,并将记录违反策略的情况)或SELINUX=disabled
。
重新启动以确保更改符合预期。
有了此更改,我的CentOS 8 VM现在可以毫无问题地运行tile服务器。
答案 1 :(得分:1)
这是先前帖子的副本,因为未经格式化就无法阅读。它显示了我用来启动OpenMapTiles-Server容器的最终启动脚本。
mkdir -p /home/mapprov/Mapping/logs/apt
mkdir -p /home/mapprov/Mapping/logs/supervisor
mkdir -p /home/mapprov/Mapping/logs/nginx
sudo podman run -d \
-v /home/mapprov/Mapping:/data:ro,z \
-v /home/mapprov/Mapping/logs:/var/log:rw,z \
-p 8080:80/tcp \
klokantech/openmaptiles-server