Hi Liang,

I suspect that you are using an old version of docker engine, maybe less
that 1.x ?

Could you please run `docker version` and `docker info` to check that you
have a version >= 1.0 ?

Also with 1.0, docker engine official tcp port has been moved to 2375 (2376
for https) so probably you need to edit also DOCKER_OPTS.

HTH,
Andrea




On Wed, Aug 13, 2014 at 11:53 PM, liang cheng <liang.ch...@gmail.com> wrote:

> Hi Andrea,
>
> Below is my code I believe as minimal to run jclouds-docker.
>
>       ComputeServiceContext context = ContextBuilder.newBuilder("docker")
>               .credentials("root", "default")
>               .endpoint("http://172.31.11.23:4243";)
>               .modules(ImmutableSet.<Module> of(new SLF4JLoggingModule(),
>                                                 new SshjSshClientModule()))
>               .buildView(ComputeServiceContext.class);
>
>       TemplateBuilder b = context.getComputeService().templateBuilder();
>
>
>
> b.imageId("a9de1b8ac7fbf0629c173bc9a71609ef46d0fc533ef089c5a42c8b36eb15194a");
>
>       Set<? extends NodeMetadata> nodes =
> context.getComputeService().createNodesInGroup("container", 1,
>
>
> b.imageId("a9de1b8ac7fbf0629c173bc9a71609ef46d0fc533ef089c5a42c8b36eb15194a").build());
>
>
> ======
> I have been able to curl and get the response from 172.31.11.23:4243
> manually. But when I run this program, I got the java error like a json
> parsing error. Can you help ?
>
>
> Exception in thread "main" java.lang.IllegalStateException: Expected STRING
> but was BEGIN_ARRAY
> at
>
> com.google.gson.internal.bind.JsonTreeReader.nextString(JsonTreeReader.java:154)
>  at
> com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:358)
> at
> com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:346)
>  at
>
> com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
> at
>
> com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
>  at
>
> com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
> at
>
> com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
>  at com.google.gson.Gson.fromJson(Gson.java:803)
> at com.google.gson.Gson.fromJson(Gson.java:868)
> at com.google.gson.Gson.fromJson(Gson.java:841)
>  at
>
> org.jclouds.docker.config.DockerParserModule$ContainerTypeAdapter.deserialize(DockerParserModule.java:58)
> at
>
> org.jclouds.docker.config.DockerParserModule$ContainerTypeAdapter.deserialize(DockerParserModule.java:51)
>  at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
> at com.google.gson.Gson.fromJson(Gson.java:803)
>  at com.google.gson.Gson.fromJson(Gson.java:768)
> at com.google.gson.Gson.fromJson(Gson.java:717)
> at org.jclouds.json.internal.GsonWrapper.fromJson(GsonWrapper.java:42)
>  at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:82)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:76)
>  at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:62)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:42)
>  at
> org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:91)
> at
> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
>  at
> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
> at
>
> org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
>  at
>
> com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
> at com.sun.proxy.$Proxy50.inspectContainer(Unknown Source)
>  at
>
> org.jclouds.docker.compute.strategy.DockerComputeServiceAdapter.listNodes(DockerComputeServiceAdapter.java:187)
> at
>
> org.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies.listDetailsOnNodesMatching(AdaptingComputeServiceStrategies.java:122)
>  at
>
> org.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies.listNodes(AdaptingComputeServiceStrategies.java:112)
> at
>
> org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.getNextNames(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:192)
>  at
>
> org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.execute(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:121)
> at
>
> org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:210)
>  at docker.main(docker.java:104)
>
> ====
> Thanks,
> -Liang
>
>
> On Fri, Aug 8, 2014 at 12:06 AM, Andrea Turli <andrea.tu...@gmail.com>
> wrote:
>
> > Yes Liang,
> >
> > try with
> >
> >       ContextBuilder builder = ContextBuilder.newBuilder(provider)
> >                                              .credentials(identity,
> > credential)
> >                                              .endpoint("
> > http://172.22.22.22:2375";)
> >                                              .modules(modules)
> >                                              .overrides(properties);
> >
> > assuming that you have enabled the docker remote API over tcp
> >
> > You can find a lot on the internet about that, but as an example, if your
> > docker engine runs on Ubuntu you can update DOCKER_OPTS in
> > /etc/init/docker.conf:
> >
> > DOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'
> >
> > and then
> >
> > service docker restart
> >
> > HTH,
> > Andrea
> >
> >
> >
> >
> > On Fri, Aug 8, 2014 at 2:25 AM, liang cheng <liang.ch...@gmail.com>
> wrote:
> >
> > > [github on Bcc]
> > >
> > > Hi Andrea,
> > >
> > > Actually what I meant is how to specify the "Linux host" in the diagram
> > of
> > > this link <http://jclouds.apache.org/guides/docker/>.For example, I'm
> > > working on workstation (172.11.11.11) and want to create docker
> container
> > > at a LInux host (172.22.22.22). How do I pass "172.22.22.22" to
> > > jclouds-docker API ? Using "endpoint" ? Please advise it.
> > >
> > > Thanks,
> > > -Liang
> > >
> > >
> > > On Wed, Aug 6, 2014 at 11:33 PM, Andrea Turli <
> notificati...@github.com>
> > > wrote:
> > >
> > > > By default, Docker assigns a NAT'ed IP to the created container which
> > is
> > > > parsed in the Container domain class
> > > >
> > > > If you need more advanced networking configuration you can try
> > > >
> http://jpetazzo.github.io/2013/10/16/configure-docker-bridge-network/
> > or
> > > > https://docs.docker.com/articles/networking/ but those are untested
> > > > solutions out of the scope of jclouds, at the moment.
> > > >
> > > > —
> > > > Reply to this email directly or view it on GitHub
> > > > <
> > >
> >
> https://github.com/jclouds/jclouds-labs/commit/9b124ee9f12e0392b6d2f083308297bfcca8ea79#commitcomment-7297454
> > > >
> > > > .
> > > >
> > >
> >
>

Reply via email to