Unable to start a Docker container through Remote Docker Java API -


i beginner docker technology , have been attempting build java app capable of starting , stopping existing docker containers.

for purpose had been using java docker api client - docker-java. https://github.com/docker-java/docker-java , had been using https://github.com/docker-java/docker-java/wiki test cases observe how api works have not been able find related tutorials.

using code, have enabled java application create docker container using following code sample.

createcontainerresponse container = client.createcontainercmd("chirangaalwis/docker-whale")                 .withcmd("/bin/sh -c '/usr/gam")                 .exec(); 

but have been unsuccessful in starting container created using java application , throws out following exception:

exception in thread "main" com.github.dockerjava.api.internalservererrorexception: cannot start container 485386a92b34c5aaf53793207e5c6a8146295b23602c9d0adf86d64a1b27d031: write /sys/fs/cgroup/cpuset/docker/485386a92b34c5aaf53793207e5c6a8146295b23602c9d0adf86d64a1b27d031/cpuset.cpus: invalid argument      @ com.github.dockerjava.core.util.responsestatusexceptionfilter.filter(responsestatusexceptionfilter.java:53)     @ org.glassfish.jersey.client.clientfilteringstages$responsefilterstage.apply(clientfilteringstages.java:139)     @ org.glassfish.jersey.client.clientfilteringstages$responsefilterstage.apply(clientfilteringstages.java:127)     @ org.glassfish.jersey.process.internal.stages.process(stages.java:171)     @ org.glassfish.jersey.client.clientruntime.invoke(clientruntime.java:259)     @ org.glassfish.jersey.client.jerseyinvocation$1.call(jerseyinvocation.java:671)     @ org.glassfish.jersey.client.jerseyinvocation$1.call(jerseyinvocation.java:668)     @ org.glassfish.jersey.internal.errors.process(errors.java:315)     @ org.glassfish.jersey.internal.errors.process(errors.java:297)     @ org.glassfish.jersey.internal.errors.process(errors.java:228)     @ org.glassfish.jersey.process.internal.requestscope.runinscope(requestscope.java:444)     @ org.glassfish.jersey.client.jerseyinvocation.invoke(jerseyinvocation.java:668)     @ org.glassfish.jersey.client.jerseyinvocation$builder.method(jerseyinvocation.java:428)     @ org.glassfish.jersey.client.jerseyinvocation$builder.post(jerseyinvocation.java:334)     @ com.github.dockerjava.jaxrs.startcontainercmdexec.execute(startcontainercmdexec.java:28)     @ com.github.dockerjava.jaxrs.startcontainercmdexec.execute(startcontainercmdexec.java:13)     @ com.github.dockerjava.jaxrs.abstrdockercmdexec.exec(abstrdockercmdexec.java:53)     @ com.github.dockerjava.core.command.abstrdockercmd.exec(abstrdockercmd.java:29)     @ com.github.dockerjava.core.command.startcontainercmdimpl.exec(startcontainercmdimpl.java:53)     @ lk.ac.iit.java_docker.dockerwithjavaclass.main(dockerwithjavaclass.java:36)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ com.intellij.rt.execution.application.appmain.main(appmain.java:140) 

this code sample using above purpose:

import com.github.dockerjava.api.dockerclient; import com.github.dockerjava.api.command.createcontainerresponse; import com.github.dockerjava.api.model.container; import com.github.dockerjava.api.model.info; import com.github.dockerjava.api.model.searchitem; import com.github.dockerjava.core.dockerclientbuilder; import com.kpelykh.docker.client.model.containercreateresponse;  import java.util.list;  /**  * created chiranga on 7/29/15.  */ public class dockerwithjavaclass {     public static void main(string[] args) {         dockerclient client = dockerclientbuilder.getinstance("http://localhost:2375").build();          system.out.println("this client " + client);         system.out.println();          info info = client.infocmd().exec();         system.out.println(info);         system.out.println();          createcontainerresponse container = client.createcontainercmd("chirangaalwis/docker-whale")                 .withcmd("/bin/sh -c '/usr/gam")                 .exec();          client.startcontainercmd(container.getid()).exec();     } } 

based on exception messsage, changed code such id printed along full path given, led new exception follows:

exception in thread "main" com.github.dockerjava.api.dockerexception     @ com.github.dockerjava.core.util.responsestatusexceptionfilter.filter(responsestatusexceptionfilter.java:55)     @ org.glassfish.jersey.client.clientfilteringstages$responsefilterstage.apply(clientfilteringstages.java:139)     @ org.glassfish.jersey.client.clientfilteringstages$responsefilterstage.apply(clientfilteringstages.java:127)     @ org.glassfish.jersey.process.internal.stages.process(stages.java:171)     @ org.glassfish.jersey.client.clientruntime.invoke(clientruntime.java:259)     @ org.glassfish.jersey.client.jerseyinvocation$1.call(jerseyinvocation.java:671)     @ org.glassfish.jersey.client.jerseyinvocation$1.call(jerseyinvocation.java:668)     @ org.glassfish.jersey.internal.errors.process(errors.java:315)     @ org.glassfish.jersey.internal.errors.process(errors.java:297)     @ org.glassfish.jersey.internal.errors.process(errors.java:228)     @ org.glassfish.jersey.process.internal.requestscope.runinscope(requestscope.java:444)     @ org.glassfish.jersey.client.jerseyinvocation.invoke(jerseyinvocation.java:668)     @ org.glassfish.jersey.client.jerseyinvocation$builder.method(jerseyinvocation.java:428)     @ org.glassfish.jersey.client.jerseyinvocation$builder.post(jerseyinvocation.java:334)     @ com.github.dockerjava.jaxrs.startcontainercmdexec.execute(startcontainercmdexec.java:28)     @ com.github.dockerjava.jaxrs.startcontainercmdexec.execute(startcontainercmdexec.java:13)     @ com.github.dockerjava.jaxrs.abstrdockercmdexec.exec(abstrdockercmdexec.java:53)     @ com.github.dockerjava.core.command.abstrdockercmd.exec(abstrdockercmd.java:29)     @ com.github.dockerjava.core.command.startcontainercmdimpl.exec(startcontainercmdimpl.java:53)     @ lk.ac.iit.java_docker.dockerwithjavaclass.main(dockerwithjavaclass.java:39)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ com.intellij.rt.execution.application.appmain.main(appmain.java:140) 

the following change made code before got above new exception:

client.startcontainercmd("/sys/fs/cgroup/cpuset/docker/" + container.getid() + "/cpuset.cpus").exec(); 

i totally new technology , grateful if provide me explained solution problem , if better alternative(s) achieve task exist, please specify.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -