palantir/docker-compose-rule

commands fail on my computer

sdyura opened this issue · 4 comments

What happened?

i can not use docker from java on my computer because for some unknown reason my computer has a smaller internal shell width then my friends

when i am trying to get the external port of a service, i use port method:

docker.containers().container("my-service-name").port(8080).getExternalPort()

here is the stack trace of the call as ive paused with the debugger on the parsing of the output

at com.palantir.docker.compose.connection.Ports.parseFromDockerComposePs(Ports.java:52)
at com.palantir.docker.compose.execution.DefaultDockerCompose.ports(DefaultDockerCompose.java:228)
at com.palantir.docker.compose.execution.DelegatingDockerCompose.ports(DelegatingDockerCompose.java:127)
at com.palantir.docker.compose.execution.RetryingDockerCompose.ports(RetryingDockerCompose.java:22)
at com.palantir.docker.compose.connection.Container.getDockerPorts(Container.java:125)
at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:167)
at com.palantir.docker.compose.connection.Container.port(Container.java:87)
at my.code.App.getExternalPortOfService(App.java:47)

the command that was executed by the java is something like this:

docker-compose -p XXXXXX ps my-service-name

and on my friends computer, the debugger shows the output of this command as:

            Name                           Command               State                 Ports              
----------------------------------------------------------------------------------------------------------
c11bfc1e_my-service-name_1      /docker-entrypoint.sh --ve ...   Up      0.0.0.0:32865->8080/tcp, 8443/tcp

now the code use a reg-ex to parse this output

com.palantir.docker.compose.connection.Ports.PORT_PATTERN = Pattern.compile("((\\d+).(\\d+).(\\d+).(\\d+)):(\\d+)->(\\d+)/tcp");

and for my friend, this works fine and everything works

but on my computer the debugger shows the result of the command like this:

         Name                   Command           State           Ports         
--------------------------------------------------------------------------------
c11bfc1e_my-service-     /docker-entrypoint.sh    Up      0.0.0.0:32865->8080/tc
name_1                   --ve ...                         p, 8443/tcp           

and as you can see the tcp in the Ports col is wrapped round, and so the reg-ex does not spot it

this means that all my code fails as it needs to get the port to be able to run.

i do not know why my computer seems to have a smaller internal width then my friends, maybe they have a bigger screen then me. but either way, this is a purely internal process, this command is never actually seen unless you use a debugger to see inside java, so it should not be limited by some external factors.

What did you want to happen?

it should work on my computer

This has been fixed in 1.4.2. Let me know if you still have problems.

@sdyura Unfortunately we went on winter break just before you posted your comment! I'm looking at why the build is failing today, now we're back.

Ok, it was a permissions problem that has now been fixed. The 1.4.2 version has published and you should be able to use it now.