Tag: java

Execute JUnit tests inside Docker container

I would like to build a test environment with Docker, where I can remotely send JUnit test classes (including the code that is tested), execute the tests and retrieve the results. I found some articles which explained how to use docker for testing databaseconntection/writing inside a redis, but not how i can simple let my […]

BadRequestException: HTTP 400 Bad Request when try to start a docker container with spotify docker-client

I’m trying to start an existing image with spotifi docker-client. My code snippet is below final DockerClient docker = DefaultDockerClient.fromEnv().build(); final ContainerConfig containerConfig = ContainerConfig.builder().hostConfig(hostConfig).image(“3298e7596fb5”).attachStdin(true).attachStderr(true).attachStdout(true).build(); final ContainerCreation creation = docker.createContainer(containerConfig); final String id = creation.id(); final ContainerInfo info = docker.inspectContainer(id); docker.startContainer(id); When running this I’m getting below exception DefaultDockerClient:578 – Creating container with ContainerConfig: ContainerConfig{hostname=null, […]

Jenkins Slave can't read settings.xml

I have created a jenkins slave image for Docker, which I want to use to build all of my Java projects, however, I can’t work out how to reference the .m2/settings.xml file to tell it where to pull from. My Dockerfile is: FROM openjdk:8 MAINTAINER Chris Hudson <chudson@amelco.co.uk> RUN apt-get -qqy update && \ apt-get […]

Deploying to dockerized Jboss Zip Exception

It´s works fine on my mac. But when I deploy the ear file (or the war that´s inside) I get a zip exception error. My docker image use centos:latest, I yum´d unzip, I use JBoss EAP 6.4 and the latest server JDK from Oracle. I have the same problem either if I copy the ear […]

How to build a docker container for a java app

What I want to do is build a docker image for my Java application but the following considerations should be true for most compiled languages. problem On my build server I want to produce a docker image for my application as the deliverable. For this I have to compile the application using some build tool […]

Running Integration tests from a Docker image for Java project

I am new to Docker and currently working on a project which uses docker for build and deployment. I have installed Docker for windows on my Windows 10 machine and currently running docker in windows environment. I am using Jenkins for creating the docker image for a project which has Integration tests coded inside it. […]

Java process inside docker is consuming more memory than the specified Xmx limit

Im running a java process inside a docker. I have set the xms(388m) and xmx(388m). Sometime after the application is started, the memory consumption of the container exceeds and reaches most ~host memory size and the container gets killed. When i connect to the java process using jprofiler i see that the heap is less […]

OpenJDK 1.8.0 in Docker container has different timezone than /etc/timezone and from the host

I have a Linux box running a Docker container, which is running TomEE, and running a WAR I built. On the base Linux box, I get a “date” value of “Fri Jan 20 10:37:27 PST 2017”. The TZ environment variable is not set. When I run the following class: import java.util.Date; import java.util.TimeZone; public class […]

Call java application launched from another container

Here’s situation. I have one container with php code and php-fpm – this is my application container. Sometimes main application calls java application – jar file. So I decided to split those technologies and make seperate java container with this java application. Now I need a way to call jar file launched inside another container. […]

Delete file inside docker container using java

I have below code: public static void main(String args[]) { try{ String[] arguments = new String[] {“rm”,”-rf”, “/home/test1″}; Process proc = new ProcessBuilder(arguments).start(); }catch(Exception e){ System.out.println(e.getMessage()); } } I am copying this file inside docker container named “java-project” and compiling/executing it using this command: docker exec -i java-project bash -c “cd /tmp; cat > $1.java;javac […]

Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.