I am trying to Dockerize a system where I should run bash script, which calls python3 script and then jar file. But openjdk Docker base doesn't come with python, and its container doesn't seem to support ubuntu based apt-get install commands. Any suggestions ?
You just need to use the java container based on buster instead of buster-slim. openjdk:buster
To test it run the following
docker run -it openjdk:buster /bin/bash
apt update
apt -y upgrade
apt -y install python3
Related
I am trying to create a Docker container for a micro-service in SpringBoot Java in Ubuntu 21.10, but when I try to build the container I get this error, maybe it is a common error, but so far I can't solve it, I have checked some posts on Internet but had no luck finding a similar solution. Please I would really appreciate the help! Thank you in advance
This is my Dockerfile:
FROM ubuntu
RUN yum install -y java
VOLUME /tmp
ADD target/microservice-0.0.1-SNAPSHOT.jar app.jar
RUN sh -c 'touch /app.jar'
ENTRYPOINT ["java", "-Djava.security.egd-file:/dev/./urandom","-jar","/app.jar"]
This is the error I get:
docker build -t spring_boot_docker .
Sending build context to Docker daemon 17.72MB
Step 1/6 : FROM ubuntu
---> 54c9d81cbb44
Step 2/6 : RUN yum install -y java
---> Running in a2793e79925b
/bin/sh: 1: yum: not found
The command '/bin/sh -c yum install -y java' returned a non-zero code: 127
In ubuntu you can try installing with apt-get:
RUN apt-get update && \
apt-get install -y openjdk-8-jdk
I want to create an image of openjdk15 and python
I am trying the Dockerfile for buid
FROM openjdk:15
RUN yum install -y oracle-epel-release-el7
RUN yum install -y python36
But when i try to build the image it shows
/bin/sh: yum: command not found
The command '/bin/sh -c yum install -y oracle-epel-release-el7' returned a non-zero code: 127
I checked the image also
$ docker run --rm -it --entrypoint "" openjdk:15 sh -c "cat /etc/os-release"
NAME="Oracle Linux Server"
VERSION="8.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.3"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.3
It seems that yum is not available on this image. It uses microdnf as package manager. Simply use following dockerfile to install python 3.6 :
FROM openjdk:15
RUN microdnf install python36
After building and running a container with shell process I received :
bash-4.4# python3 -V
Python 3.6.8
im trying to install psycopg2 to use postgres on my django app. Seems like the first step is to run the
sudo apt install python3-dev libpq-dev
, but when i do it hits me with this funky error -
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/bin/apt" (-1)
I'm confused as to why its showing me a java error when i'm installing python-dev. Any help would be greatly appreciated!
Install pip by typing:
python3 -m pip install --user --upgrade pip
It is often a good idea to use virtual environments when doing projects, otherwise packages are installed system wide.
Type in the following to start a virtual environment in your project directory:
python3 -m pip install --user virtualenv
python3 -m venv .
Afterwards, this command should install psycopg2
pip install psycopg2-binary==2.8.4
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 have to run Django CRM in my local machine. I followed all commands and tried to install every dependency.
I got stuck in the following command.
sudo apt-get install oracle-java8-installer -y java -version
I got the following error when I tried above command.
E: Command line option 'e' [from -version] is not understood in combination with the other options.
The link of Github CRM Django CRM
Documentation
Please someone help me.
Looking to Django-CRM documentation, seems like the command to install java (required by elasticsearch dependency) it's not the correct one for ubuntu 18.04
To install it you need to run:
apt-get install openjdk-8-jre-headless
Then you can follow the instructions as in the documentation
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch > key.elastic
apt-key add key.elastic
echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
apt-get update && apt-get install elasticsearch -y
Also, remember to add sudo on the commands if you are not running the commands as root