使用Spotify Maven Docker插件,如何更改添加到Docker容器的资源的文件权限?

使用Spotify Maven Docker插件 ,如何更改添加到Docker容器的资源的文件权限? 例如,在下面的Maven Docker插件定义中,我如何指示Maven使脚本wait-for-file.sh可执行文件?

  <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.4.9</version> <configuration> <imageName>opes/${project.artifactId}</imageName> <imageTags> <imageTag>${project.version}</imageTag> <imageTag>latest</imageTag> </imageTags> <baseImage>opes/tomcat</baseImage> <maintainer>Derek Mahar &lt;dmahar@opessoftware.com&gt;</maintainer> <resources> <resource> <targetPath>/usr/local/tomcat/webapps</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.war</include> </resource> <resource> <targetPath>/</targetPath> <directory>src/main/docker</directory> <include>wait-for-file.sh</include> </resource> </resources> </configuration> </plugin> 

我想maven应该复制资源与用户的权限。

试试maven-antrun-plugin。 例:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>permission</id> <phase> <!-- a lifecycle phase --></phase> <goals> <goal>run</goal> </goals> <configuration> <target> <chmod file="/wait-for-file.sh" perm="755"/> </target> </configuration> </execution> </executions> </plugin> 

希望这可以帮助

据我所知,Spotify Maven Docker插件没有提供一个命令来显式地改变它复制到Docker容器的文件的权限。

然而, Fabric8 Maven Docker插件确实提供了这样的命令,再加上它比Spotify插件更多的function。

这是我的解决scheme:

pom.xml

  <plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.15.1</version> <configuration> <images> <image> <name>opes/${project.artifactId}</name> <build> <tags> <tag>latest</tag> <tag>${project.version}</tag> </tags> <from>opes/tomcat</from> <maintainer>Derek Mahar &lt;dmahar@opessoftware.com&gt;</maintainer> <assembly> <mode>tgz</mode> <basedir>/</basedir> <descriptor>assembly.xml</descriptor> </assembly> </build> </image> </images> </configuration> </plugin> 

src/main/docker/assembly.xml

 <?xml version="1.0" encoding="UTF-8"?> <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> <id>platinum-oms</id> <files> <file> <source>${project.build.directory}/${project.build.finalName}.war</source> <outputDirectory>usr/local/tomcat/webapps</outputDirectory> </file> <file> <source>src/main/docker/wait-for-file.sh</source> <outputDirectory>/</outputDirectory> <fileMode>544</fileMode> </file> </files> </assembly> 

如果您好奇, Fabric8会比较Docker Maven Plugin Shootout中的几个Maven Docker插件。