Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow listen address to be configured alongside port #429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cburroughs
Copy link
Contributor

This is useful if cases where collins runs on a node with multiple
interfaces, or behind a proxy.

This is useful if cases where collins runs on a node with multiple
interfaces, or behind a proxy.
@byxorna
Copy link
Contributor

byxorna commented Mar 25, 2016

LGTM! Could you add this to the Dockerfile's entrypoint as well?

@cburroughs
Copy link
Contributor Author

I don't think the Dockerfile has a precedent for configuration like this. For example the port is just hard coded as -Dhttp.port=9000``and that is relied upon by theEXPOSE` statement.

@byxorna
Copy link
Contributor

byxorna commented Mar 25, 2016

@cburroughs it would be nice to have listen.address explicitly set to 0.0.0.0, but totally not necessary for this PR.

@william-richard
Copy link
Contributor

@cburroughs maybe this is because I'm running docker 1.10.0, but I was able to add the following to the dockerfile and it respected the environment variable.

$ git diff Dockerfile
diff --git a/Dockerfile b/Dockerfile
index 32b7e9f..72caa23 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,7 +30,8 @@ WORKDIR /opt/collins
 # You probably will want to override these configs in production
 COPY conf/docker conf/

+ENV PORT 9000
+
 # expose HTTP, JMX
-EXPOSE 9000 3333
+EXPOSE $PORT 3333
 CMD ["/usr/bin/java","-server","-Dconfig.file=/opt/collins/conf/production.conf","-Dhttp.port=9000","-Dlogger.file=/opt/collins/conf/logger.xml","-Dnetworkaddress.cache.ttl=1","-Dnetworkaddress.cache.negative.ttl=1","-Dcom.sun.management.jmxremote","-Dcom.sun.management.jmxremote.port=3333","-Dcom.sun.management.jmxremote.authenticate=false","-Dcom.sun.management.jmxremote.ssl=false","-XX:MaxPermSize=384m","-XX:+CMSClassUnloadingEnabled","-cp","/opt/collins/lib/*","play.core.server.NettyServer","/opt/collins"]
-

And then when I built and inspected the container, I got port 9000 exposed:

$ docker inspect will-collins
[
    {
        "Id": "sha256:bf93647bd4735d032e9814a44090ec2fc0bb4a8849cadfc8f654af39adc890f0",
        "RepoTags": [
            "will-collins:latest"
        ],
        "RepoDigests": [],
        "Parent": "sha256:42c864b87c4b0aa9475a88fa1b78d3ddecfe4164dc0b7ffcbde711fbf3585a93",
        "Comment": "",
        "Created": "2016-03-28T15:47:49.588022328Z",
        "Container": "c9f22977a400f761729b282c2086c46af0503e7d03d5d46cf03e93d73096c91f",
        "ContainerConfig": {
            "Hostname": "e5c68db50333",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "3333/tcp": {},
                "9000/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre",
                "JAVA_VERSION=8u72",
                "JAVA_DEBIAN_VERSION=8u72-b15-1~bpo8+1",
                "CA_CERTIFICATES_JAVA_VERSION=20140324",
                "PORT=9000"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) CMD [\"/usr/bin/java\" \"-server\" \"-Dconfig.file=/opt/collins/conf/production.conf\" \"-Dhttp.port=9000\" \"-Dlogger.file=/opt/collins/conf/logger.xml\" \"-Dnetworkaddress.cache.ttl=1\" \"-Dnetworkaddress.cache.negative.ttl=1\" \"-Dcom.sun.management.jmxremote\" \"-Dcom.sun.management.jmxremote.port=3333\" \"-Dcom.sun.management.jmxremote.authenticate=false\" \"-Dcom.sun.management.jmxremote.ssl=false\" \"-XX:MaxPermSize=384m\" \"-XX:+CMSClassUnloadingEnabled\" \"-cp\" \"/opt/collins/lib/*\" \"play.core.server.NettyServer\" \"/opt/collins\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:42c864b87c4b0aa9475a88fa1b78d3ddecfe4164dc0b7ffcbde711fbf3585a93",
            "Volumes": {
                "/opt/collins/conf/solr/cores/collins/data": {}
            },
            "WorkingDir": "/opt/collins",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
..... <more stuff here>

So I think we could set the port using an environment variable in the Dockerfile, and make all of the scripts used in the container respect that variable to change the port that gets used. Not sure if it's worth doing or not though, since at runtime it could be changed. Maybe this is a job for docker's build-args, but I haven't used them before so I don't have a good idea of how they work yet.

@discordianfish
Copy link
Contributor

I'd not use the script with the Dockerfile. I personally never used those scripts and in general try to avoid using 'vendor scripts' to bring up my services. I think it's fine to provide them here for convenience, but wouldn't change the Dockerfile to use it.

So IMO, this can get merged. Is there something else blocking it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants