How to add RUN Commands with docker-maven-plugin in pom.xml

1.2k Views Asked by At

I have been using Dockerfile for my project with a sample code like given below.

RUN groupadd syslog && apt-get update && apt-get -q install -y curl logrotate iproute2

I would like to convert this to pom.xml so that other micro-services can inherit it.

I surely cannot add this under build tag as I cannot and don't want this to get executed at the build time, I rather want this to set up logrotate in the container when the container starts up.

I tried adding few run commands, but that did not work. I am trying to understand which XML tag needs to be used for making sure my container RUNs the command on start up?

Your guidance will be highly appreciated.

1

There are 1 best solutions below

0
On

Try runs:

  <plugin>
      <groupId>com.spotify</groupId>
      <artifactId>docker-maven-plugin</artifactId>
        
      <configuration>
        <runs>
          <run>groupadd syslog</run>
          <run>apt-get update</run>
          <run>apt-get -q install -y curl logrotate iproute2</run>
        </runs>
      </configuration>
    </plugin>