In one folder I have two files: Dockerfile and postgresql-42.2.4.jar
Dockerfile:
from ubuntu:16.04
RUN apt-get update && apt-get install -y \
libreoffice-base
COPY postgresql-42.2.4.jar postgresql-42.2.4.jar
CMD ["usr/bin/libreoffice"]
postgresql-42.2.4.jar:
I downloaded PostgreSQL JDBC archive from PostgreSQL official site
To run docker I used:
docker build -t gui-app .
then:
docker run --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" gui-app
Libre Office run correctly, but when I want to add Class Path (link to Libre help site) I can't find .jar file which I copied in Dockerfile.
I didn't manually install JRE, but I think JRE is build in ubuntu.
Why I can't find JDBC archive file?
There is no JRE installed by default in the docker image ubuntu:16.04. You can inspect the list of installed packages by running:
docker run -it ubuntu:16.04 apt list
You can install the default JRE in your Dockerfile by adding the default-jre package:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y \
libreoffice-base default-jre
COPY postgresql-42.2.4.jar postgresql-42.2.4.jar
CMD ["usr/bin/libreoffice"]
Related
So I am trying to install OpenJDK in a Dockerfile but I am having issues. It always errors with the following message: Sub-process /usr/bin/dpkg returned an error code (1) and then underneath The command bin/sh returned a non-zero code: 100. This is the command that failed to execute. Currently on Ubuntu 20.04 VM
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY Folder/*.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet build -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:5.0
# Install OpenJDK-14
RUN apt-get update && \
apt-get install -y default-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/default/
RUN export JAVA_HOME
RUN apt-get install -y supervisor # Installing supervisord
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
WORKDIR /app
COPY Folder/Lavalink/* ./
COPY --from=build-env /app/out .
#ENTRYPOINT ["dotnet", "Application.dll"]
ENTRYPOINT ["/usr/bin/supervisord"]
Here is the supervisord as well
[supervisord]
nodaemon=true
[program:folder]
command=dotnet /app/Application.dll
[program:lavalink]
command=java -jar /app/Lavalink.jar
This is a Visual Studio project written in 5.0 with a .jar file that needs to be executed.
These didn't seem to help:
apt-get update' returned a non-zero code: 100, Docker File Non-Zero Code 100 Error When Building Basically what I am trying to achieve is to install java within a container. Preferably java 13 but this issue prevents me from doing so. Last, it is important to let you know that the same commands works on another container.
Add this before installing the jdk :
RUN mkdir -p /usr/share/man/man1/
This is a problem in the debian slim images and this image is based on buster-slim. Alternatively you can try to use one of the dotnet/runtime images based on Ubuntu (5.0-focal) or Alpine (5.0-alpine).
I am using this docker-compose.yaml file to run airflow on docker container.
https://airflow.apache.org/docs/apache-airflow/2.0.2/docker-compose.yaml
I need to install JRE in one of the containers. How do I add instruction to add java to the docker-compose.yaml file?
Try the following:
Create the following Dockerfile in the directory where you also have the docker-compose.yml:
FROM apache/airflow:2.0.2
USER root
# Install OpenJDK-11
RUN apt update && \
apt-get install -y openjdk-11-jdk && \
apt-get install -y ant && \
apt-get clean;
# Set JAVA_HOME
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/
RUN export JAVA_HOME
USER airflow
WORKDIR /app
COPY requirements.txt /app
RUN pip install --trusted-host pypi.python.org -r requirements.txt
In order to install packages via apt, you have to switch to root user. Later, we switch back to user airflow. The specification of the working directory and the installation of python packages through requirements.txt might not apply, depending on your case.
Then, in your docker-compose.yml, add build: . after &airflow-common.
Finally, build your pipeline using docker-compose up -d --build.
For more information, look here: https://airflow.apache.org/docs/docker-stack/build.html#building-the-image
You have to build your own airflow image.
In your Dockerfile you have to apt install the airflow and export JAVA_HOME.
Dockerfile example:
FROM apache/airflow:2.5.1
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-11-jre-headless \
&& apt-get autoremove -yqq --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
USER airflow
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
RUN pip install --no-cache-dir apache-airflow-providers-apache-spark==2.1.3
Build command example:
docker build -t airflow-with-java .
After successfully image building edit your docker-compose by replacing airflow image:
x-airflow-common:
&airflow-common
image: ${AIRFLOW_IMAGE_NAME:-airflow-with-java}
More information you can look here: https://airflow.apache.org/docs/docker-stack/build.html
What I would like is to add Java (installation and JAVA_HOME) in an image.
I'm using this postgres dockerfile: https://github.com/docker-library/postgres/tree/master/9.6
Which I updated with the following :
RUN apt-get -y update
RUN apt-get -y install wget
RUN apt-get -y install sudo
RUN /bin/mkdir /usr/lib/jvm
RUN wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
RUN sudo tar xfvz /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz --directory /usr/lib/jvm
RUN rm -f /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
ENV JAVA_HOME /etc/alternatives/jre
Please note that I'm beginner so if something is obvious for you it may not be for me.
The issue is that, /usr/lib/jvm is not created thus java is not installed and also JAVA_HOME is empty when I run the image.
When I execute manually the instructions, it works, but I would like to make my dockerfile working.
I'm trying to Dockerize a Gauge test automation project so I can run specs inside a Docker container. The project is written in Java and Spring Boot.
I saw this tutorial in Gauge documentation.
This is the DockerFile in the tutorial:
FROM ubuntu
# Install Java.
RUN apt-get update && apt-get install -q -y \
openjdk-8-jdk \
apt-transport-https \
gnupg2 \
ca-certificates
# Install gauge
RUN apt-key adv --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys 023EDB0B && \
echo deb https://dl.bintray.com/gauge/gauge-deb stable main | tee -a /etc/apt/sources.list
RUN apt-get update && apt-get install gauge
# Install gauge plugins
RUN gauge install java && \
gauge install screenshot
ENV PATH=$HOME/.gauge:$PATH
As you see, there's no "ADD"/"COPY" there in the DokcerFile.
Is it just suggesting an alternative to install Gauge and the other packages on the host?
Any ideas on how to run the specs inside a Docker container?
Here is what I did to get the test running in the docker container.
I have a specs folder beside src in my project structure meaning the gauge tests will run using the JAR file but they're not part of the JAR file themselves.
--MyProject
----specs
----src
...
I used maven to run the test inside the container. That's why I preferred to build the project inside the container so I get the JAR file ready with the same version of maven I run the test with.
Here is the DockerFile. I developed a bash script to run the test. You may run the script with CMD or ENTRYPOINT:
FROM maven:3.6.1-jdk-8
# add any project resources needed
ADD env /home/e2e/env
ADD specs /home/e2e/specs
ADD src /home/e2e/src
ADD src/main/scripts/entrypoint.sh /home/e2e/
ADD pom.xml /home/e2e/
RUN ["chmod", "+x", "./home/e2e/entrypoint.sh"]
# Install Gauge, web browser and webdriver in your preferred way...
ENV PATH=$HOME/.gauge:$PATH
# I'm keeping the cntainer running. But it's all up to you.
CMD /home/e2e/entrypoint.sh && tail -f /dev/null
And then here is the simple entrypoint.sh script:
#!/bin/bash
cd /home/e2e/
mvn clean package
gauge --version
google-chrome --version
mvn -version
mvn gauge:execute -DspecsDir=specs/myTest.spec
Of course, you could just use a ready JAR instead of building it inside the container. Or you could build the JAR while creating the docker image.
I have developed a simple Java App in windows which I now want to distribute for LINUX/UNIX machine. How should I package the JRE with my application so that it could be run on target UNIX machine with no JRE or JDK installed ?
Package your application with Docker(https://www.docker.com/), using the Java DockerFile (http://dockerfile.github.io/#/java)?
############################################################
# Dockerfile to run a Java based Application
# Based on an Ubuntu Image
############################################################
#Set the base image to use to Ubuntu
FROM ubuntu:14.04
# Set the file maintainer (your name - the file's author)
MAINTAINER NB
# Set env variables used in this Dockerfile (add a unique prefix, such as DOCKYARD)
# Local directory with project source
#TO DO
# Install JDK and JRE
RUN apt-get update
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:webupd8team/java -y
RUN apt-get update
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf- set-selections
RUN apt-get install oracle-java8-installer -y
RUN apt-get install oracle-java8-set-default
# Copy entrypoint script into the image
WORKDIR $DOCKYARD_SRC
COPY ./run.sh /
ENTRYPOINT ["/run.sh"]