question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docs and troubleshooting

See original GitHub issue

I’m not sure if this is a bug report or a support request; 48 hours and I haven’t been able to do hello world stuff, create iamge.

I’ve been trying to use this package to do the following, locally on windows at first than on azure/gcloud:

  • create image from docker file: ideally without using a docker file… I figure with a package like this you could define all parameters in a object instead, which would allow me to treat my server containers like all other objects which I thought would be pretty cool… I’ve been just trying to get an image created with a dockerfile recently because I’m not sure if the prior is even possible with this (no docs I found say).
  • build it
  • push it
  • mount it
  • etc

But I can’t seem to create an image. Errors range from “can’t find docker file” to " unexpected EOF" to completing without error but no image showing up locally.

Worth noting, I’m trying to use kotlin not java… is that my problem? Also, I need this to work regardless of how it’s deployed Jar/War/uncompressed.

Here is the folder structure… docker client/http tests work locally, the following content is in Docker.kt and the svrDB is my dockerfile. image

Here is what I got so far, it’s a mess from trial and error. If I was smart I’d just use the gradle docker plugin and move along… but it seems a shame not to do this in code if possible, to treat my docker servers like objects would be fantastic!


package com.app.build.containers

import com.github.dockerjava.api.command.BuildImageResultCallback
import com.github.dockerjava.core.DefaultDockerClientConfig
import com.github.dockerjava.core.DockerClientConfig
import com.github.dockerjava.core.DockerClientImpl
import com.github.dockerjava.httpclient5.ApacheDockerHttpClient
import com.github.dockerjava.transport.DockerHttpClient
import java.io.File

const val projectName: String = "srcBuild"

class DockerApi {
    private val config: DockerClientConfig = DefaultDockerClientConfig.createDefaultConfigBuilder()
        .withDockerHost("tcp://localhost:2375")
        //.withDockerTlsVerify(true)
        //.withDockerCertPath("/home/user/.docker")
        //.withRegistryUsername("admin")
        //.withRegistryPassword("password")
        //.withRegistryEmail("gunslingor@gmail.com")
        //.withRegistryUrl("https://index.docker.io/v1/")
        .build()

    val httpClient: DockerHttpClient = ApacheDockerHttpClient.Builder()
        .dockerHost(config.dockerHost)
        .sslConfig(config.sslConfig)
        .build()

    val dockerClient = DockerClientImpl.getInstance(config, httpClient)!!
    val file = DockerApi::class.java.classLoader.getResourceAsStream("dockerfiles/svrDB")

}

fun main(){
    val dockerApi = DockerApi()
    val clientDocker = dockerApi.dockerClient
    val result = clientDocker.infoCmd().exec()
    //val filePath = dockerApi.file
    //print(filePath)

    clientDocker.createImageCmd("test", dockerApi.file).exec()
    clientDocker.listImagesCmd()
/*
    clientDocker.buildImageCmd(dockerApi.file)
        //.withPull(true)
        //.withNoCache(true)
        //.withTags(setOf("app_dck_dev_svr_build"))
        .exec(BuildImageResultCallback())
        .awaitImageId();

 */
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

19reactions
winthrop-polkcommented, Jul 16, 2020

I have not but I will review it in more detail… I don’t usually like to dig into someone else’s code to understand their package, Packages should be atomic by the time they get to me and well documented with instructions… nothing less efficient than reverse engineering IMHO, faster to just run docker commands at the CLI and build up an API. So the real process to use this package is to download the entire code base correct? If so, do I still need to download your compiled packages too via gradle? Seems silly to do both… where should I put your project and what IDE should I be using? I don’t see the idea folder so assume it shouldn’t be intelliJ… lot to manually string together otherwise.

No worries, I don’t really have enough time to put into it, this is 1/1000 packages I was hoping to use in my next app… I couldn’t even identify the create Image test, no idea about your coding policies are here. Will probably just run docker CLI commands from code unless you see that as problematic.

4reactions
bsideupcommented, Jul 17, 2020

@winthrop-polk docker-java is a low level library that allows calling the Docker API. You need to understand the API to be able to work with it.

all I know is docker CLI took about 45 minutes to learn what I needed and I’m really struggling with this package

Docker CLI wraps the API and provides high-level commands on top of it (like docker run which is a combination of “create container” + “start container” + “attach to container”).

. I don’t seem to understand why HTTP is even needed, or why it still wouldn’t be as simple as defining a connection and running something like “docker.image.build(“test2”, “svrDB”)” against it.

You’re free to find (or create) a library on top of docker-java which will give you docker.image.build(...)-like experience. This, however, is out of scope of docker-java.

question: many of those tests relly on dockerRule, where is that coming from?

This is a class in the same source set. I would suggest to learn a little bit more about Java, how projects are structured, etc etc. docker-java is a standard Maven project and you should have no issues grasping it once you get enough knowledge of Java and Maven-based Java projects.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix common issues in Google Drive
2. Try basic troubleshooting ... If you see a “Trying to connect” error message, or if your documents are very slow to load...
Read more >
Troubleshooting docs guide | New Relic Documentation
Our troubleshooting docs have these main sections: problem, solution, and (optionally) cause. Otherwise, a troubleshooting doc uses the basic doc template ...
Read more >
Microsoft troubleshooting documentation
Find the documentation you need to troubleshoot issues and apply workarounds for the following commercial products from Microsoft.
Read more >
Troubleshooting: Smart Docs - Knowledge Base | Pipedrive
In this article, you'll find a few troubleshooting tips in case you run into any loading or connecting issues while using the Smart...
Read more >
6 fast fixes for common Google Docs problems - Computerworld
6 fast fixes for common Google Docs problems · Google Docs problem No. 1: Edit regret · Google Docs problem No. 2: Case...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found