Docker-maven-plugin: Avoiding chown to reduce the image size

Created on 25 Aug 2016  路  6Comments  路  Source: fabric8io/docker-maven-plugin

The issue #175 introduced an extra layer for the chown that is doubling the content size of the chown ed folder (for an image containing the jdk+jboss it could be huge).
Is it possible to avoid this extra layer using a single CMD (without the COPY)?

By doing a curl and chown in the same RUN command, this drastically reduces the image size, but in this case I have to use an external Dockerfile and I'd prefer being fully maven-style (using the assembly).

Any idea how to fix this?

Most helpful comment

The feature is included in Docker 17.09 and up quoted from moby/moby#6119

All 6 comments

I see the point, but I wonder how we could doing the COPY / ADD from the assembly and the chown in one layer. The real pita is that https://github.com/docker/docker/issues/6119 doesnt get fixed.

If you have an idea I'm happy to add this as an optimization.

@rhuss Hi Roland, as moby/moby#6119 is fixed now, could you please kindly make an optimization?

Good point, will start working on it hopefully soonish. Do you know the Docker (or even better API) version, since when these flags are available ?

The feature is included in Docker 17.09 and up quoted from moby/moby#6119

I also noticed another downside of current implementation.
Since the temporary directory name is randomly generated, docker can't reuse the build cache even if the content of the assembly is not changed.

image

Using --chown would solve this too.

@rohanKanojia If you have some spare cycles (not necessarily for the next release), could you give a look to get rid of our own chown mechanism and use that from Docker (for Docker >= 17.09) ?

Was this page helpful?
0 / 5 - 0 ratings