Skip to content

Dockerfile generalizations (Expose, Volume) #440

@darklajid

Description

@darklajid

Hi.

Setting up Oxalis for a cloud environment here. I have two requirements: I persist to a database (readonly filesystem) and listen to a "random" port. I'm aware that I can do that already today by my own¹, but I want to make a case for adapting the Dockerfile upstream to be more generic nevertheless: That way a shared binary artifact can be used globally.

  1. The EXPOSE line

As discussed in #426: right now the image has a baked in hard-coded port. With closing #437 (thanks again!) we can now pass in environment variables into the oxalis.conf, so a dynamic oxalis.jetty.port set so something like ${PORT} is now possible - I can set it/control it from outside. But the exposed 8080 for the image is static.

I'd argue that EXPOSE isn't required in general². I would expect users of the image to use docker run -p to map the jetty port to a specific external port and that doesn't need the EXPOSE.

More discussions about different combinations of docker run invocations / EXPOSE settings here for example: https://stackoverflow.com/a/22150099/59492

The docker ecosystem understands that this is not nice and has a specific issue for EXPOSE being impossible to unset³ which was closed in favor or an issue tracking a more generic issue talking about changing/overriding/unsetting various parent properties⁴ (directly related to my next point).

  1. The VOLUME line

Adding a VOLUME definition to the image is irreversible - using that image as base you won't be able to remove them afterwards. There are multiple discussions online for this elsewhere (Oracle: oracle/docker-images#640 linking to https://forums.docker.com/t/why-use-the-volume-instruction/55420 for example). As above in 1) the docker ecosystem is aware of this problem⁴, but there is currently no solution other than 'ask upstream to change it' or 'fork the Dockerfile and build it yourself'.

The question here is if that HAS to be in the base image or could be either a runtime choice or be part of a derived image?

--

My proposal, if you allow: In an Ideal World² there would be an image on https://hub.docker.com/r/difi/oxalis that contains neither EXPOSE nor VOLUME definitions. This hypothetical image could be called oxalis-base maybe? The current images could still work as-is if they'd derive from that theoretical oxalis-base and literally just need the EXPOSE and VOLUME lines if those are actually required elsewhere. This way this issue would be fixed in an entirely backwards compatible and transparent way.

Again: The benefit I see would be that - for a hopefully minor change on the difi / oxalis side - downstream users would be able use the very same binary image everywhere. Today, if your infrastructure doesn't work well with EXPORT or VOLUME, you have to fork the Dockerfile, remove those definitions and build your own Oxalis.

I understand that this puts some (small?) amount of extra effort on difi. If you are at all open to the idea of splitting the build, I'd offer to work on a proposal / pull request to make this as painless as possible.

① So, I clearly understand a "WorksForMe" response :-p
② Obviously I'm biased / looking at this from my specific perspective. If you disagree I'd be glad to understand your use case / reasoning though
moby/moby#2210
moby/moby#3465

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions