Trying to create a Dockerfile that'll download and install Java 8 on Amazon Linux.
Currently, I have the following file. It's a Play 2.3.4 app:
FROM dockerfile/java
RUN \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
apt-get install -y oracle-java8-installer && \
rm -rf /var/lib/apt/lists/*
MAINTAINER BeanstalkTest
EXPOSE 80 443
ADD files /
WORKDIR /opt/docker
RUN ["chown", "-R", "daemon", "."]
USER daemon
RUN ["bin/playapp", "-Dconfig.file=conf/prod.conf"]
The app takes a long time to deploy then fails. Any ideas what I could be doing wrong?
For me it looks like problem with connection.
Are you sure that this code works without Docker inside target host?
Does it work in your machine?
Are you sure that echo command is doing what you really want ? I mean installing java 8.
Ok so I will post my ideas:
Set up proxies: HTTP_PROXY, http_proxy, HTTPS_PROXY, https_proxy, http-proxy, https-proxy - yes that many proxies because different packages use different names of proxy.
Add proxy to etc/apt/apt.conf to Acquire::http::Proxy "http://proxy-abc.com:888/";
Add proxy to docker:
Inside etc/default/docker:
export http_proxy=http://proxy-abc.com:888/
export https_proxy=https://proxy-abc.com:888/
DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix://var/run/docker.sock -g /docker"
Look at docker container logs: sudo cat log/var/lib/docker/containers/12eaca16d3cdc628304263b21d27614e5a0c44f09c2072470b09a1bb3def5559/12eaca16d3cdc628304263b21d27614e5a0c44f09c2072470b09a1bb3def5559-json.log
Does your target host has newest kernel ? In older kernels docker had problems with network communication
Does your target host had newest docker installed?
EDIT
Why wouldn't use prebuild images? FROM dockerfile/java:oracle-java8
Related
I am totally newbie to Docker. My task is to create such environment to be able to work Spring Boot app on in and what's more I want to have also Heroku CLI installed also (I perform operations between databases on two different accounts using heroku:pg copy). What's more its size should be as small as it is possible and reach max 500MB (would be best if even less) that is quota for Heroku account
Here is my Dockerfile:
FROM ubuntu
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-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;
# Install sudo
RUN apt-get update && \
apt-get -y install sudo
# Add user and switch to it
RUN useradd -m login && echo "login:password" | chpasswd && adduser login sudo
USER login
# Install curl and use curl
RUN echo "password" | sudo -S apt --assume-yes install curl
RUN echo "password" | sudo -S curl https://cli-assets.heroku.com/install.sh -o ~/heroku.sh
# Run Heroku script
RUN echo "password" | sudo -S sh ~/heroku.sh
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
# Add an app and listen on port
ADD target/project-server-1.0-SNAPSHOT.jar .
COPY project-91878452-firebase-adminsdk-dxv9z-0db48a2d01.json /
EXPOSE 8000
CMD java -jar project-server-1.0-SNAPSHOT.jar
This code works, I tested that locally but on Heroku there is an error on start saying that size has been considerably exceeded.
So what should I change in Dockerfile to make image size based on this Dockerfile as small as it is possibke and meet the requirements mentioned at the beginning of the post?
Kind regards!
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).
To insall java 8 on docker container, I used this command in dockerfile
RUN curl -LO 'http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.rpm'
-H 'Cookie: oraclelicense=accept-securebackup-cookie' RUN rpm -i jdk-8u111-linux-x64.rpm RUN rm jdk-8u111-linux-x64.rpm
It worked for awhile, but now this link is not no longer available. Is there replaceable url for this? or easy way to insall java 8 on docker?
It's up to your using OS, so I'd like you to show your OS. For example, Ubuntu users prepares their ppa repository for Oracle Java.
RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update
RUN apt-get install oracle-java8-installer
It seems that Oracle has changed the authorization for downloading, the actual link that the browser uses is http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm?AuthParam=1496223138_c808095f7637d83147c37d69d3a87e7a, but this cannot be used with curl.
I have no solution for the problem with downloading from Oracle, but I use the official OpenJDK image as base and have found no problems with that.
If openjdk is OK for you, you can use
RUN apt-get install -y openjdk-8-jdk
openjdk, in contrast to oracle, does not require user's confirmation.
If you only need java runtime, consider openjdk-8-jre.
Adaption of my Dockerfile from https://hub.docker.com/r/sftech/java
FROM ubuntu
ENV JAVA_VERSION=8
RUN echo oracle-java${JAVA_VERSION}-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& apt-add-repository ppa:webupd8team/java \
&& apt-get update \
&& apt-get install -y oracle-java${JAVA_VERSION}-installer \
&& update-java-alternatives -s java-${JAVA_VERSION}-oracle \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Why would you install java in an image / container, when you can get a java:8 image from the Docker store for free. The license requirements are exactly the same as the java / jdk download install from the oracle.com website.
I am not sure why I expected this to work:
# Dockerfile
FROM node:6
FROM java:8
but it doesn't really work - looks like the first command is ignored, and second command works.
Is there a straightforward way to install both Node.js and Java in a Docker container?
Ultimately the problem I am trying to solve is that I am getting an ENOENT error when running Selenium Webdriver -
[20:38:50] W/start - Selenium Standalone server encountered an error: Error: spawn java ENOENT
And right now I assume it's because Java is not installed in the container.
The best way for you is to take java (which is officially deprecated and it suggests you use openjdk image) and install node in it.
So, start with
FROM openjdk:latest
This will use the latest openjdk image, which is 8u151 at this time. Then install node and other dependencies you might need:
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh
You might want to install things like grunt afterwards, so this might come in handy as well.
RUN npm install -g grunt grunt-cli
In total you will get the following Dockerfile:
FROM openjdk:latest
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh \
RUN npm install -g grunt grunt-cli
You may clone the Dockerfile from my gitlab repo here
You can use single FROM per generated image.
Try to use node as a base image and install java to it.
Dockerfile
FROM node:latest
RUN apt-get -y install default-jre
You can choose the version you need:
apt install default-jre
apt install openjdk-11-jre-headless
apt install openjdk-8-jre-headless
You can also use the node image and then install the default-jre:
# Dockerfile
FROM node:latest
RUN apt-get -y install default-jre
You can choose the version you need:
apt install default-jre
apt install openjdk-11-jre-headless
apt install openjdk-8-jre-headless
Perhaps, you might want to try this https://hub.docker.com/r/timbru31/java-node one to create the docker file.
This docker image comes with both Java and Node pre-installed. It comes in handy when both are required as a dependency.
Something like,
FROM timbru31/java-node:<tag>
The FROM inside your dockerfile simply tells docker from which image it should start the configuration. You can't simply concatenate multiple images together. There are already multiple container images available which offer preinstalled Java 8 and node JS. I don't want to recommend any image specifically but will direct you to docker-hub for you to go search on your own and use the container that suites your needs the best.
With version 14 of node it works perfectly for me:
FROM openjdk:latest
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh \
RUN npm install -g grunt grunt-cli
this worked for me:
FROM openjdk:16-slim-buster
RUN apt-get update; apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh
This works for me with node v16.15.0, be careful with the packages version of java, I'm using the latest by default. The packages used for java are:
Java Runtime Environment (jre)
Java Development Kit (jdk)
FROM node:16.15.0
RUN apt-get update \
&& apt-get install default-jre -y \
&& apt-get install default-jdk -y
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
RUN npm install --global nodemon
COPY . .
EXPOSE 3000
CMD ["npm", "run", "dev"]
I hope this works for you all
I am new to docker and I have tried following some tutorials and documentation on USING DOCKER TO EFFICIENTLY CREATE MULTIPLE TOMCAT INSTANCES, but am having trouble getting the service to run via the docker run command.
I have a docker file with the following coding below
FROM ubuntu:precise
MAINTAINER Quinten Krijger < qkrijger [at] gmail {dot} com>
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update && apt-get -y install python-software-properties
RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update && apt-get -y upgrade
RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get -y install oracle-java7-installer && apt-get clean
RUN update-alternatives --display java
RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle" >> /etc/environment
When I build using the command
docker build -t quintenk/jdk7-oracle .
it shows the build is successful.
In the another dockerfile, I try to create create other images based on it
I have another docker in a different path with the following commands
FROM quintenk/jdk7-oracle
MAINTAINER Quinten Krijger "qkrijger#gmail.com"
RUN apt-get -y install tomcat7
RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle" >> /etc/default/tomcat7
EXPOSE 8080
CMD service tomcat7 start && tail -f /var/lib/tomcat7/logs/catalina.out
I use the following command to run the docker file
docker run -d quintenk/tomcat7
But it shows as tomcat instance fail
* Starting Tomcat servlet engine tomcat7
...fail!
If I give the command
docker ps
also there is no instance running on my machine
I'm obviously doing something wrong and I'm getting the behaviour on my OSX
For testing you can create a Dockerfile with CMD ["bash"].
start the container then login to the container using the command
docker -it exec container_name bash
then start tomcat and checkout out the tomcat logs
Try running the image with following command
docker run -dt --cap-add SYS_PTRACE quintenk/tomcat7
I have faced this issue. Finally, I am able to run the tomcat.Follow below steps.
Step-1: open terminal Ctrl+Alt+t
Step-2: then on terminal go inside the running container, type commands
sudo docker exec -it containerID /bin/bash
Now to check tomcat is running or not, type your container IP address followed by colon(:) 8080 port on the browser. like 172.17.0.2:8080.
Hope it helps!!