Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container not starting using #385

Open
bastien-snk opened this issue Jun 2, 2022 · 3 comments
Open

Container not starting using #385

bastien-snk opened this issue Jun 2, 2022 · 3 comments

Comments

@bastien-snk
Copy link

Hey, i have a problem with starting containers, sometimes it displays me this error, here is an example of the JSON that is sent to Docker Engine API to create the container. The creation is always successful, but startup isn't. But it doesn't happen only for this container. Char 80 corresponds to a random char in the JSON. It tells me each times char 80.

try {
    Container container = DockerManager.getInstance().getDocker().containers().get(containerName);
    if(container == null) return;
    container.start();
} catch (IOException e) {
    e.printStackTrace();
}
{
  "Image": "itzg/minecraft-server:java8",
  "AutoRemove": true,
  "Domainname": "test-lobby",
  "Env": [
    "TYPE\u003dCUSTOM",
    "CUSTOM_SERVER\u003d/data/server.jar",
    "EULA\u003dTRUE",
    "SERVER_NAME\u003dtest-lobby"
  ],
  "HostConfig": {
    "PortBindings": {
      "25565/tcp": [
        {
          "HostPort": "62207"
        }
      ]
    },
    "Mounts": [
      {
        "Target": "/data",
        "Source": "C:\\Users\\basti\\Documents\\GitHub\\TestDocker\\src\\main\\resources\\modules\\lobby\\server",
        "Type": "bind",
        "ReadOnly": false
      }
    ]
  },
  "Tty": true,
  "OpenStdin": true,
  "Volumes": {}
}

Exception in thread "main" javax.json.stream.JsonParsingException: Unexpected char 80 at (line no=1, column no=1, offset=0)
at org.glassfish.json.JsonTokenizer.unexpectedChar(JsonTokenizer.java:532)
at org.glassfish.json.JsonTokenizer.nextToken(JsonTokenizer.java:415)
at org.glassfish.json.JsonParserImpl$NoneContext.getNextEvent(JsonParserImpl.java:222)
at org.glassfish.json.JsonParserImpl$StateIterator.next(JsonParserImpl.java:172)
at org.glassfish.json.JsonParserImpl.next(JsonParserImpl.java:149)
at org.glassfish.json.JsonReaderImpl.readObject(JsonReaderImpl.java:101)
at com.amihaiemil.docker.PayloadOf.lambda$new$1(PayloadOf.java:81)
at com.amihaiemil.docker.JsonResource.(JsonResource.java:64)
at com.amihaiemil.docker.PayloadOf.(PayloadOf.java:77)
at com.amihaiemil.docker.MatchStatus.handleResponse(MatchStatus.java:95)
at com.amihaiemil.docker.MatchStatus.handleResponse(MatchStatus.java:43)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
at com.amihaiemil.docker.HttpClientEnvelope.execute(HttpClientEnvelope.java:103)
at com.amihaiemil.docker.RtContainer.start(RtContainer.java:93)
at dev.lyramc.seedplant.modules.lobby.LobbyInstance.start(LobbyInstance.java:50)
at dev.lyramc.seedplant.managers.docker.DockerManager.load(DockerManager.java:40)
at dev.lyramc.seedplant.managers.Manager.initManagers(Manager.java:21)
at dev.lyramc.seedplant.SeedPlant.(SeedPlant.java:18)
at dev.lyramc.seedplant.Main.main(Main.java:6)

@0crat 0crat added the 0crat/new label Jun 2, 2022
@amihaiemil
Copy link
Owner

@rootxls I will look into this, but keep in mind that this library is still a prototype.

You can do a lot of stuff with it, but there is also a lot of functionality which is not yet implemented.

Before using it in Production, or anything serious, please have a look into it, see if it has everything that you need.

@bastien-snk
Copy link
Author

@amihaiemil I know, don't worry the lib has everything I need! I looked the src. And for unimplemented features I can always use the queries by hand. I prefer that to using other java libs that are not documented at all and not clear about the methods.

@amihaiemil
Copy link
Owner

amihaiemil commented Jun 4, 2022

@rootxls to be honest, I'm not sure what the problem might be. First of all, make sure you're using the right instance of Docker (see here). I guess you're using the right class, otherwise it wouldn't work at all.

Have you tried debugging? We also publish the sources of this lib, so you should have them in your IDE, to go into the PayloadOf class and see what comes there.

Most likely, the problem is that the status is correct (e.g. 200 OK), but the body payload is not a JSON as expected. Have a look into the API documentation of your Docker version, maybe it returns something else if the container is already started. If you find something, please post it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants