67 questions
0
votes
1
answer
496
views
java.lang.ClassNotFoundException: org.apache.hc.client5.http.ssl.TlsSocketStrategy when using docker-java API 3.5.0
I'm trying to use the Docker-Java API. Following the instruction in https://github.com/docker-java/docker-java/blob/main/docs/getting_started.md I build a DockerClientConfig and try to build a ...
0
votes
1
answer
410
views
Why is the Docker Java client unable to connect to the Docker daemon?
I’m trying to connect my Spring Boot application to the Docker daemon using the docker-java library, but I’m encountering the following error:
java.lang.RuntimeException: org.apache.hc.client5.http....
0
votes
1
answer
151
views
Why can't I push an image to a local Docker registry started with Testcontainers?
I'm trying to create a local Docker registry using Testcontainers and push an image programatically to it. However, I'm getting a connection refused error when attempting to push the image. The first ...
0
votes
1
answer
338
views
Manage docker with docker-java, the volume mapping seems not working
Environment:
Fedora 39
openjdk-17
docker 25.01
My purpose is to run ffmpeg to merge Multiple video files into a single file, and i choose to use docker(manage by com.github.docker-java:docker-java:3.3....
0
votes
1
answer
346
views
LinkageError after adding javax.ws.rs-api to Gradle build in Spring Boot 3.2 Kotlin project
Initial Error:
Encountered a NoClassDefFoundError when building with Docker Java API on a spring boot "3.2.1" Kotlin 1.9.21 project
java.lang.NoClassDefFoundError: javax/ws/rs/core/...
0
votes
0
answers
165
views
Wait for the completion of the command execution launched via the docker-java library
I have a docker-swarm stack with a number of services, one of which is a java application container that needs to launch a command in the shell of another container. The two services are deployed on ...
1
vote
1
answer
395
views
docker-java equivalent for 'docker exec {container name} touch test.txt'
I am trying to run an exec command on an already running docker container on a remote host using java.
I am successfully able to run the exec command from the CLI of the host machine using
docker exec ...
1
vote
1
answer
208
views
ocrmypdf not working when using the docker image and the docker java client over a binding volume
When running an ocrmypdf docker container, all I get is the following message:
ocrmypdf: error: unrecognized arguments: 64ee37a6fc66cf591ce4a35f-1.png_OCR.pdf
This is what my docker inspect container ...
1
vote
1
answer
2k
views
java.lang.NoClassDefFoundError: com/github/dockerjava/api/command/LoadImageAsyncCmd
I am trying to create a Docker client with the Docker Java API, but I get a ClassNotFoundException when running my code. I am following this Baeldung guide,
but I am using the latest version of docker-...
0
votes
1
answer
231
views
Is it possible to execute custom commands with the Docker Java API?
Can the Docker Java client library (https://github.com/docker-java/docker-java) be used to execute custom commands?
I want to use the library to check if Docker images I need to download are ...
1
vote
1
answer
3k
views
Use CMD parameters in distroless image
I am using azul/zulu-openjdk-distroless:17.0.6 image and want to execute the java command with parameters but it fails at the runtime
Here is my docker image:
FROM alpine:3.17.3 as build-env
ARG ...
3
votes
1
answer
2k
views
How can I parse an existing docker container into testcontainers?
I have an existing PostGres docker container running in the background. Is it possible to create a GenericContainer that will parse the existing PostGres container by taking in the container ID, ...
3
votes
2
answers
5k
views
Testcontainers with sftp image throws Error on "nc not found" or "Address Not Available"
I have this very simple code for running my integration test:
(using Testcontainer artifact version 1.16.2)
Note: I have tested whether this port in test is available before running the test case.
@...
0
votes
1
answer
378
views
Running Docker command in java
I'm trying to run this command in docker trough java, but i don't know why it only works when i execute the command in the host machine and not trough java (when execute on java it doesn't add or say ...
0
votes
1
answer
670
views
docker-Java stop timeout
i'm using the java-docker client from here: https://github.com/docker-java/docker-java.
I trying to figure out how to set the stop timeout for the docker stop command.
So i'm using in java the method ...
0
votes
0
answers
1k
views
Docker: different java versions in interactive and non-interactive modes
Here is my Dockerfile
FROM ubuntu:20.04
# Install java 8 with apt-get
RUN apt-get update -qq && apt-get install -yqq openjdk-8-jdk
# Install java 11 with sdkman
RUN apt-get install -yqq curl ...
18
votes
3
answers
24k
views
Testcontainer cannot configure port binding
I'm using testcontainer version 1.15.2. Tests are run in intellij on windows 10.
I have a wiremock container. By default it listens on the port 8080. I would like to map this port to let's say 8081. ...
1
vote
1
answer
1k
views
Accessing the output of a command running in a docker container
I'm trying to upgrade from docker-java 0.10.3 to 3.2.7. This line has me completely stumped:
InputStream response =
dockerClient.attachContainerCmd(container.getId())
.withLogs(true)
....
1
vote
1
answer
874
views
Get Docker Image Name when loading image to docker using docker-java lib
I am trying to load image to docker from tar file and verify if the tar file is valid or not.
Now if tar file is valid I need to get the imageName and tag.
But I checked and the return type for exec ...
0
votes
1
answer
369
views
About the withCmd command of docker-java
I want to ask how I use the withCmd method as follows:
commands = new String[]{"echo","test:111 | chpasswd"};
ExecCreateCmdResponse execCreateCmdResponse = dockerClient....
-1
votes
1
answer
1k
views
How to run a java swing application with Docker because docker run command throws headless exception
When I try to run the java swing image getting the "Headless Exception error"
DockerFile:
FROM openjdk:8
COPY requiredlibararies requiredlibraries
COPY myjar.jar myjar.jar
CMD ["java&...
2
votes
1
answer
1k
views
Docker Binding parse exception with testcontainers
I would like to run some integrational tests which would include setting up a complete environment with org.testcontainers Docker Compose Module. I am new to Windows and Docker testing, same with the ...
3
votes
1
answer
12k
views
Socket read interrupted during callback from Docker Java
Context
I have a webservice writing a test id in a queue. Then, a listener reads the queue, searches the test and starts it. During those steps, it writes updates of the test in the database in order ...
0
votes
1
answer
1k
views
How can I get the hostname of a container using docker-java?
I can create, start and retrieve an instance of a docker container like this:
CreateContainerResponse response = dockerClient.createContainerCmd(imageId).exec();
String containerId = response.getId();
...
0
votes
2
answers
751
views
List images in Google Container Registry in Java program
We wanted to list images and tags which names start with certain string. So far, we explored a few java lib (docker-java and spotify ones) and did quite amount of research, but still couldn't find a ...
1
vote
0
answers
354
views
how to start docker container with detach for docker-java?
I am trying to run a docker image using the following code. But the container is exiting immediately after starting. I don't find -d params at creating container. how to do?
HostConfig hostConfig = ...
5
votes
1
answer
377
views
How to get output of docker executed command in docker-java library
I am trying to pull an alpine image using docker-java library. Image got pulled successfully but I am not seeing any docker output on console. How to enable logging in docker-java library.
public ...
1
vote
1
answer
665
views
can't create a docker image with java. Error msg is "......: Error processing tar file(exit status 1): unexpected EOF"
I use Java to build a Docker image. The Dockerfile and code are ready. I can build an image successfully through CLI, such as:
docker build -t imgetest:1.0 .
My Dockerfile is:
FROM node:6.14.2
...
-1
votes
2
answers
3k
views
Not able to access web app running inside docker container from local machine
I am using windows 10 enterprise version and i have tested docker hello world web app it works just fine.
Dockerfile
FROM adoptopenjdk/openjdk11:latest
WORKDIR /app
COPY ./ ./
EXPOSE 3000
CMD ["...
0
votes
2
answers
1k
views
Not able to start docker container with shell script
This is the start.sh script i am using:
#!/bin/bash
touch app.log
HEAP_SIZE="-Xms1G -Xmx2G"
GC_ARGS="-XX:+UseG1GC -XX:+UseStringDeduplication -XX:+HeapDumpOnOutOfMemoryError"
ARGS="$HEAP_SIZE $...
2
votes
0
answers
489
views
How can I log docker-java operations to the console?
I'm using the docker-java library in a command-line project, doing things like this:
private DockerClient client;
public Docker() {
var config = DefaultDockerClientConfig
...
-1
votes
1
answer
193
views
docker-java: access containers on docker host
I am creating docker containers inside my java application (using docker-java). I want to make the containers (all from the same image) accessible for the host.
Preferably all the containers listen ...
1
vote
1
answer
1k
views
docker-java run container with -rm flag
I am using docker-java to spawn new containers.
I want to remove the containers after they are finished.
Is there a way to achieve this with docker-java?
So I basically want something like
docker ...
2
votes
2
answers
4k
views
How to run a docker container from within java
I want to run the following command from within a Java Eclipse Project:
docker container run -p 4000:5000 virtuprint:vp
where virtuprint:vp is an image.
I installed the docker-java api from here ...
0
votes
1
answer
786
views
How to check if an image is already present locally
I am using the docker-java Maven library, and I would like to know if there is a way to check if an image has already been pulled or is present locally before pulling it if necessary, with only the ...
1
vote
2
answers
981
views
How to find CPU MEMORY usage with docker stats command?
I am using docker-java API to execute docker API in my project. I didn't find any suitable method which lists down docker CPU memory usage as
GET /v1.24/containers/redis1/stats HTTP/1.1 with the help ...
0
votes
2
answers
455
views
docker-java equivalent of "docker service create --with-registry-auth"
Using https://github.com/docker-java/docker-java and looking for a way to add the --with-registry-auth option from https://docs.docker.com/v17.12/engine/reference/commandline/service_create/#options
...
0
votes
0
answers
2k
views
Why am I getting "https://registry-1.docker.io/v2/{reponame}/tags/list: unauthorized: incorrect username or password"?
Summary
I am trying to use the docker-java library but I am running into a problem when I try to pull an image. I am trying to pull from a private repository on ECR.
What I have tried
Much of the ...
2
votes
2
answers
9k
views
How to get the docker host URI on my localhost
Is there a command that I can evaluate (eval $COMMAND) or an environment variable that I can inspect to get the URI of the locally running docker host? I need to be this an expression to evaluate at ...
3
votes
2
answers
3k
views
How to get list of existing containers ids by Docker-java
In Java code I need to manage docker containers (restart, stop, start ...) using Docker-java library.
https://github.com/docker-java/docker-java
In Docker-Java examples I found the way to create and ...
0
votes
1
answer
135
views
Docker: Publishing ports from a user-defined network to a specific host IP address with docker-java
I'm trying to achieve something similar to this:
-p 192.168.1.100:8080:80
with docker-java. The only example that I found for publishing/mapping ports with docker-java is using the .withExposedPorts ...
4
votes
3
answers
13k
views
How add setup before @SpringBootTest and only run once?
I have a docker DB setup method, which currently located in @BeforeAll.
Currently, Construct as below
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public ...
5
votes
0
answers
637
views
TestContainers: reuse network from DockerComposeContainer to use in other GenericContainer?
There is a method:
org.testcontainers.containers.GenericContainer#withNetwork
which I can use to spawn containers with a same network using TestContainers lib.
But what about DockerComposeContainer,...
1
vote
0
answers
208
views
MSSQL DB Instance connection issue through SQLCMD when using inside a docker container
I am trying to write java code to automate the docker commands that I execute. I am actually creating a mssql docker container and then want to restore a DB backup in that container. I am able to ...
0
votes
2
answers
3k
views
Disable IPv6 in Docker container from 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 ...
1
vote
0
answers
612
views
Starting mariaDB container and start-up script with Docker
I'm creating a mariaDB container via docker run with -v pathToSQL:/docker-entrypoint-initdb.d/script.sql option via Java. I have no idea how to find out when the container is ready to be connected ...
85
votes
3
answers
197k
views
How to make curl available in Docker image based java:8-jdk-alpine and keep the image clean?
We are having java code that runs curl command to fetch the some result.
We have built a jar file and the jar file executes fine
Now, when we try to dokerize the java program (using jar) and run the ...
2
votes
2
answers
2k
views
Docker-Java: Starting container with arguments
I'm trying to start a docker container using docker-java.
Using the method DockerClient.startContainerCmd works for me, but I need to start the container with arguments.
The StartContainerCmd class ...
0
votes
1
answer
92
views
Unable to see Container Processes with docker-java
I'm using the docker-java libraries to handle start up of a Docker image:
DockerClient dockerClient = DockerClientBuilder.getInstance("unix:///var/run/docker.sock").build();
CreateContainerResponse ...
4
votes
1
answer
5k
views
Testcontainers with a company proxy
Each start of different testcontainers will throw com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"Get https://quay.io/v1/_ping: dial tcp x.x.x.x: getsockopt: connection ...