0

I need to disable IPv6 when starting a Docker container from Java code. Using the command line, it is as follows:

docker run --sysctl net.ipv6.conf.all.disable_ipv6=1 ...

  • Is it possible to do the same but using Java with Spotify's docker-client?

  • As alternative solution... would it be possible to do with docker-java?

4
  • Possible duplicate of How can I disable IPv6 stack use for IPv4 IPs on JRE? Commented Aug 2, 2018 at 9:39
  • @juanlumn My question is related with the use of Docker from Java. Commented Aug 2, 2018 at 9:50
  • @MichaelHampton My target application is not Java, in fact it is a browser in a Docker container. I want to change the settings of that container using a Java library (docker-client or docker-java) but it seems it is not possible. At least I didn't find how, for that reason I'm asking. Commented Aug 2, 2018 at 12:48
  • It doesn't appear that either of those clients supports setting sysctls on a container. Consider submitting an issue, or better, a pull request. Commented Aug 2, 2018 at 13:00

2 Answers 2

0

I think you should be able to do that with our docker-java-api (see Wiki and the linked blog post for details about it): https://www.github.com/amihaiemil/docker-java-api

In principle, it should be as simple as:

final Docker docker = new LocalDocker(...); //or new RemoteDocker(...);
final Container container = docker.containers().create(/*javax.json.JsonObject config*/);

Of course, you have to study the Docker API documentation in order to see what format the JsonObject should have (it should accept config about IpV 6 as well).

Sign up to request clarification or add additional context in comments.

Comments

0

Please follow this -

https://github.com/spotify/docker-client/blob/2966b5cad6568d3c1b23f8891fbecab110834785/src/test/java/com/spotify/docker/client/DefaultDockerClientTest.java

 final NetworkConfig networkConfig =
        NetworkConfig.builder().name(networkName).driver("bridge").checkDuplicate(true).ipam(ipam)
            .internal(false).enableIPv6(false).labels(labels)
            .build();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.