容器内使用非root用户运行 挂载的目录与容器中用户id不一致 容器内权读取挂载目录中的文件
docker-compose.yml 配置
注意user为tomcat 挂载了目录./prop
version: '2'
services:
app-batch:
container_name: app-batch-1
image: 'tomcat:8.5-jdk8'
user: tomcat
restart: always
ports:
- "9012:8080"
volumes:
- ./prop:/home/tomcat/prop
- ./webapps/batch-web.war:/home/tomcat/webapps/batch-web.war
注意./prop目录下的文件权限为640 并且属主属组与容器内不同
[root@amc212 prop]# pwd
/home/yunwei/server_bak202108/app-batch/prop
[root@amc212 prop]# ll
total 56
-rw-r----- 1 yunwei crmgrp 708 Feb 18 14:15 al-dsession.properties
drwxr-x--- 2 yunwei crmgrp 4096 Feb 18 14:15 config-cache
-rw-r----- 1 yunwei crmgrp 1431 Feb 18 14:15 CRM3.al-dsession.properties
-rw-r----- 1 yunwei crmgrp 560
|