Disable IPv6 in Docker container from Java - java

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?

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).

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();

Related

Is command line the only way to configure wildfly 10 programatically?

From what I can tell, the docs all point to the command line interface. We have a java interface that can call a section of our API that is generic that uses JMX for weblogic to configure everything. Our code would be more simple if I kept it similar between the two server types.
What I am finding is that everything I would normally configure in JMX (JDBC, Mail Sessions, JMS, etc) is documented to be called by wildfly on command line.
Is this the normal (recommended) way to configure wildfly so it is ready for your EAR deployment?
One way is to use the native management API - ModelControllerClient - in Java to do your configuration tasks:
ModelControllerClient client = ModelControllerClient.Factory
.create(new ModelControllerClientConfiguration.Builder().setHostName(HOSTNAME).setPort(9990)
.setConnectionTimeout(36000).build());
ModelNode operation = new ModelNode();
operation.get("operation").set("whoami");
operation.get("verbose").set("true");
ModelNode result = client.execute(operation);
System.out.println(result.toString());
Other way is to use the HTTP management API and do the same by this way using any fitting client (e.g. curl):
curl --digest -u admin:passwd.123 -L -D - http://localhost:9990/management \
--header "Content-Type: application/json" \
-d '{"operation":"whoami","verbose":"true","json.pretty":1}'

Orientdb cannot insert data inside docker container

I am using docker to use orientdb. Using in my localhost i managed to insert data to the database using
OServerAdmin serverAdmin = new OServerAdmin("remote:localhost:2424").connect("root","password");
However, when i try to do the same thing using docker container i manage to connect create the database but i cannot insert my data
OrientGraphFactory factory = new OrientGraphFactory("remote:172.17.0.2:2424/CartoesPagamentos").setupPool(1,10);
OrientGraph graph = factory.getTx();
Any ideas about why I can connect and create a database using the API but cannot insert any data?
EDIT :
I ran console.sh and connected to my docker container like this
CONNECT remote:172.17.0.2:2424/CartoesPagamentos root password
and i tried to insert a vertex and it worked.
Documentation about how to run the orientDB docker container:
https://hub.docker.com/_/orientdb/
You are running with this command:
docker run --name cartoesPagamentoTeste -v /orientdb/config -it orient db:latest server.sh
you're not exposing ports to localhost and it seems you are providing a config folder as volume: as stated on the doc page, if you provide (aka override) a config folder that is empty, orient will start with a very minimal configuration.
So, please, read docs linked above carefully AND read docker docs.
Are you sure that
OrientGraph graph = factory.getTx();
works?
Can you access through browser orientDb admin ui by this address 172.17.0.2 ?
Also can you check orientDb docker logs by next command:
docker logs -f {container name or hash}

Azure Storage Blob : https://(storageAccountName).blob.core.windows.net/vhd?restype=container&comp=list not working using proxy

For getting the blob container details we are using the below mentioned REST API.
Vhd is the blob container name.
https://(storageAccountName).blob.core.windows.net/vhd?restype=container&comp=list
When we use proxy server details (example:SQUID Proxy) to access the storage REST API calls, we are getting the below mentioned error.
HttpResponse for Blobs:: ResourceNotFoundThe
specified resource does not exist.
RequestId:6dc7e6f2-0001-000d-30f9-d56eb3000xxx
If we access the same rest api without proxy server, we are getting the valid response and it's working.
Per my experience, normally, using squid is as reverse proxy for backend services, but here you want to access the storage REST APIs via squid as forward proxy. You can refer to the wiki page https://en.wikipedia.org/wiki/Proxy_server, the SO thread Difference between proxy server and reverse proxy server and the blog to know the differences between both.
So the solution for the issue is that configuring the proxy server as forward proxy.
For Squid, you can try to refer to the squid wiki pages http://wiki.squid-cache.org/SquidFaq/ConfiguringSquid and http://wiki.squid-cache.org/Features/HTTPS to know how to configure as forword proxy with HTTPS.
For Apache, you can try to refer to the apache doc page http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#forwardreverse to do.
Then, setting the system properties for Java to enable proxy support after setting up forward proxy successfully.
There are two ways support proxy for Java.
Command Line JVM Settings: The proxy settings are given to the JVM via command line arguments:
java -Dhttp.proxyHost=proxyhostURL -Dhttp.proxyPort=proxyPortNumber -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword HelloWorldClass
Setting System Properties in Code: Adding the following lines in your Java code so that JVM uses the proxy to make HTTP calls.
System.setProperty("http.proxyPort", "someProxyPort");
System.setProperty("http.proxyUser", "someUserName");
System.setProperty("http.proxyPassword", "somePassword");
System.setProperty("http.proxyHost", "someProxyURL");
More information for Networking & Proxies & Properties in Java, Please refer to http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html and http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html.
we got the solution. The issue is we are invoking asynchronous calls for all storage accounts at a time. For example : if we have 5 storage accounts and each storage accounts 5 vhd containers and in for loop if we invoke all 5 at time and with callback waiting for 5 response,In this case it's not working. so we are invoking each call separately and it's started working.

JAX-WS client authentication on proxy server

I'm trying to use JAX-WS api to send some soap messages on a client application. However, I'm behind a firewall and the only option is to use a proxy server to go outside.
I'm trying to find on google any answer about this and so far all fail: To Use System.setProperty for http.proxyHost, http.proxyPort, http.proxyUser, http.proxyPassword. To use Authenticator like is described here.
I'm running out of options, if someone could help me on this would be great.
Also, I have a option to use org.apache.commons.httpclient but then I need to generate manually the XML. So could you suggest any other approach or API for WS?
You can use ws import command when creating web client to configure proxy.
-httpproxy::
use above command to configure proxy.
How to do this depend on your IDE.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/rwbs_wsimport.html
For Jax-ws webservice client, use the following
//set proxy info to the ClientProxyFeature
ClientProxyFeature cpf = new ClientProxyFeature();
cpf.setProxyHost("proxyhost");
cpf.setProxyPort(8888);
cpf.setProxyUserName("proxyuser");
cpf.setProxyPassword("proxypwd");
//get the port with the Feature
MyPort port = myService.getPort(cpf);

How to activate SSL(HTTPS) in Glassfish 3.0 embedded API?

We are implementing an application with a webservice as component and decided to use the Glassfish 3.0 embedded distri to provide the webservice. And it works.
We need a SSL(HTTPS) connection to the webservice, but we didn't find any documentation or hint how to activate it programmatically via the embedded API.
Thus we tried to configure the embedded Glassfish via domain.xml, what has a listener configured with SSL. And the port is reachable but only without SSL. The embedded Glassfish seem to ignore the configuration to activate SSL for the port.
Has anyone experience in configuring embedded Glassfish with SSL?
Ok,
sorry that it took so much time for my answer.
The programmatical embedded API seems not to porvide a way to do this task.
Except to run an asadmin command:
logger.debug("Configure port for SSL");
String command = "create-http-listener";
ParameterMap params = new ParameterMap();
params.add("listeneraddress", "0.0.0.0");
params.add("listenerport", "443");
params.add("defaultvs", "server");
params.add("securityenabled", "true");
params.add("enabled", "true");
params.add("DEFAULT", "http-listener2");
CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class);
ActionReport report = server.getHabitat().getComponent(ActionReport.class);
runner.getCommandInvocation(command, report).parameters(params).execute();
Running this code is simmlar to execute:
asadmin create-http-listener --listeneraddress 0.0.0.0 --listenerport 443 --defaultvs server securityenabled=true --enabled=true http-listener2
But this solution creates a new port with SSL. Reconfigure the already started port would be a nice option.

Categories