OpenJDK Java 11 + Maven 3.8 + Python 3.8 + pip 21 + node 16 + npm 7 + Gradle 7
** This build is based upon Ubuntu 20.04 + OpenJDK Java 11 **
** Currently Docker Hub not allowing for free hosting for Docker images: Please run ./build.sh first by yourself locally **
NOTICE: ''Change to use Non-Root implementation''
This new release is designed to support the deployment for Non-Root child images implementations and deployments to platform such as OpenShift or RedHat host operating system which requiring special policy to deploy. And, for better security practice, we decided to migrate (eventaully) our Docker containers to use Non-Root implementation.
Here are some of the things you can do if your images requiring "Root" acccess - you really
want to do it:
- For Docker build: Use "sudo" or "sudo -H" prefix to your Dockerfile's command which requiring "sudo" access to install packages.
- For Docker container (access via shell): Use "sudo" command when you need to access root privilges to install packages or change configurations.
- Or, you can use older version of this kind of base images which use "root" in Dockerfile.
- Yet, you can also modify the Dockerfile at the very bottom to remove/comment out the "USER ${USER}" line so that your child images can have root as USER.
- Finally, you can also, add a new line at the very top of your child Docker image's Dockerfile to include "USER root" so that your Docker images built will be using "root".
We like to promote the use of "Non-Root" images as better Docker security practice. And, whenever possible, you also want to further confine the use of "root" privilges in your Docker implementation so that it can prevent the "rooting hacking into your Host system". To lock down your docker images and/or this base image, you will add the following line at the very end to remove sudo: (Notice that this might break some of your run-time code if you use sudo during run-time)
sudo agt-get remove -y sudo
After that, combining with other Docker security practice (see below references), you just re-build your local images and re-deploy it as non-development quality of docker container. However, there are many other practices to secure your Docker containes. See below:
- Docker security | Docker Documentation
- 5 tips for securing your Docker containers - TechRepublic
- Docker Security - 6 Ways to Secure Your Docker Containers
- Five Docker Security Best Practices - The New Stack
Components
-
Ubuntu 20.04 LTS now as LTS Docker base image.
-
openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
-
Apache Maven 3.8
-
Python 3.8 + pip 21.2 + Python 3 virtual environments (venv, virtualenv, virtualenvwrapper, mkvirtualenv, ..., etc.)
-
Node v16 + npm 7 (from NodeSource official Node Distribution)
-
Gradle 7
-
Other tools: git wget unzip vim python python-setuptools python-dev python-numpy, ..., etc.
Quick commands
- build.sh - build local image
- logs.sh - see logs of container
- run.sh - run the container
- shell.sh - shell into the container
- stop.sh - stop the container
- tryJava.sh : test Java
- tryNodeJS.sh : test NodeJS
- tryPython.sh : test Python
- tryWebSocketServer.sh : test WebSockert NodeJS Server
How to use and quick start running?
- git clone https://github.com/DrSnowbird/jdk-mvn-py3.git
- cd jdk-mvn-py3
- ./run.sh
Default Run (test) - Just entering Container
./build.sh or 'make build'
./run.sh
Test Java, NodeJS, and Python3 Runs
./tryJava.sh
./tryNodeJS.sh
./tryPython.sh
./tryWebSockerServer.sh
Default Build (locally)
./build.sh
Pull the image from Docker Repository
docker pull openkbs/jdk-mvn-py3
Base the image to build add-on components
FROM openkbs/jdk-mvn-py3
... (then your customization Dockerfile code here)
Manually setup to Run the image
Then, you're ready to run:
- make sure you create your work directory, e.g., ./data
mkdir ./data
docker run -d --name my-jdk-mvn-py3 -v $PWD/data:/data -i -t openkbs/jdk-mvn-py3
Build and Run your own image
Say, you will build the image "my/jdk-mvn-py3".
docker build -t my/jdk-mvn-py3 .
To run your own image, say, with some-jdk-mvn-py3:
mkdir ./data
docker run -d --name some-jdk-mvn-py3 -v $PWD/data:/data -i -t my/jdk-mvn-py3
Shell into the Docker instance
docker exec -it some-jdk-mvn-py3 /bin/bash
Run Python code
To run Python code
docker run -it --rm openkbs/jdk-mvn-py3 python3 -c 'print("Hello World")'
or,
docker run -i --rm openkbs/jdk-mvn-py3 python3 < myPyScript.py
or,
mkdir ./data
echo "print('Hello World')" > ./data/myPyScript.py
docker run -it --rm --name some-jdk-mvn-py3 -v "$PWD"/data:/data openkbs/jdk-mvn-py3 python3 myPyScript.py
or,
alias dpy3='docker run --rm openkbs/jdk-mvn-py3 python3'
dpy3 -c 'print("Hello World")'
Compile or Run java -- while no local installation needed
Remember, the default working directory, /data, inside the docker container -- treat is as "/". So, if you create subdirectory, "./data/workspace", in the host machine and the docker container will have it as "/data/workspace".
#!/bin/bash -x
mkdir ./data
cat >./data/HelloWorld.java <<-EOF
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
EOF
cat ./data/HelloWorld.java
alias djavac='docker run -it --rm --name some-jdk-mvn-py3 -v '$PWD'/data:/data openkbs/jdk-mvn-py3 javac'
alias djava='docker run -it --rm --name some-jdk-mvn-py3 -v '$PWD'/data:/data openkbs/jdk-mvn-py3 java'
djavac HelloWorld.java
djava HelloWorld
And, the output:
Hello, World
Hence, the alias above, "djavac" and "djava" is your docker-based "javac" and "java" commands and it will work the same way as your local installed Java's "javac" and "java" commands.
Run JavaScript -- while no local installation needed
Run the NodeJS mini-server script:
./tryNodeJS.sh
Then, open web browser to go to http://0.0.0.0:3000/ to NodeJS mini-web server test.
Python Virtual Environments
There are various ways to run Python virtual envrionments, for example,
Setup virtualenvwrapper in $HOME/.bashrc profile
Add the following code to the end of ~/.bashrc
#########################################################################
#### ---- Customization for multiple virtual python environment ---- ####
#########################################################################
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
export WORKON_HOME=~/Envs
if [ ! -d $WORKON_HOME ]; then
mkdir -p $WORKON_HOME
fi
To create & activate your default venv environment, say, "my-venv":
mkvirtualenv my-venv
workon my-venv
To run specialty Java/Scala IDE alternatives
However, for larger complex projects, you might want to consider to use Docker-based IDE. For example, try the following Docker-based IDEs:
- openkbs/docker-atom-editor
- openkbs/eclipse-photon-docker
- openkbs/eclipse-photon-vnc-docker
- openkbs/eclipse-oxygen-docker
- openkbs/intellj-docker
- openkbs/intellj-vnc-docker
- openkbs/knime-vnc-docker
- openkbs/netbeans9-docker
- openkbs/netbeans
- openkbs/papyrus-sysml-docker
- openkbs/pycharm-docker
- openkbs/scala-ide-docker
- openkbs/sublime-docker
- openkbs/webstorm-docker
- openkbs/webstorm-vnc-docker
See also
Proxy & Certificate Setup
Corporate Proxy Root and Intemediate Certificates setup for System and Web Browsers (FireFox, Chrome, etc)
- Save your corporate's Certificates in the currnet GIT directory,
./certificates
- During Docker run command,
-v `pwd`/certificates:/certificates ... (the rest parameters)
If you want to map to different directory for certificates, e.g., /home/developer/certificates, then
-v `pwd`/certificates:/home/developer/certificates -e SOURCE_CERTIFICATES_DIR=/home/developer/certificates ... (the rest parameters)
- And, inside the Docker startup script to invoke the
~/scripts/setup_system_certificates.sh
. Note that the script assumes the certficates are in/certificates
directory. - The script
~/scripts/setup_system_certificates.sh
will automatic copy to target directory and setup certificates for both System commands (wget, curl, etc) to use and Web Browsers'.
Releases information
developer@galactica:~$ /usr/scripts/printVersions.sh
+ echo JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
+ whereis java
java: /usr/bin/java /usr/share/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/share/man/man1/java.1.gz
+ echo
+ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
+ mvn --version
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /usr/apache-maven-3.8.2
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-34-generic", arch: "amd64", family: "unix"
+ python -V
/usr/scripts/printVersions.sh: line 8: python: command not found
+ python3 -V
Python 3.8.10
+ pip --version
pip 21.2.4 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
+ pip3 --version
pip 21.2.4 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
+ gradle --version
Welcome to Gradle 7.0!
Here are the highlights of this release:
- File system watching enabled by default
- Support for running with and building Java 16 projects
- Native support for Apple Silicon processors
- Dependency catalog feature preview
For more details see https://docs.gradle.org/7.0/release-notes.html
------------------------------------------------------------
Gradle 7.0
------------------------------------------------------------
Build time: 2021-04-09 22:27:31 UTC
Revision: d5661e3f0e07a8caff705f1badf79fb5df8022c4
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.11 (Ubuntu 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OS: Linux 5.11.0-34-generic amd64
+ npm -v
7.23.0
+ node -v
v16.9.0
+ cat /etc/lsb-release /etc/os-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
Python3 PIP Modules
developer@galactica:~$ pip freeze
argon2-cffi==21.1.0
atomicwrites==1.1.5
attrs==21.2.0
backcall==0.2.0
backports.entry-points-selectable==1.1.0
beautifulsoup4==4.8.2
bleach==4.1.0
certifi==2021.5.30
cffi==1.14.6
chardet==3.0.4
charset-normalizer==2.0.4
cloudpickle==1.6.0
cycler==0.10.0
dbus-python==1.2.16
debugpy==1.4.3
decorator==5.0.9
defusedxml==0.7.1
distlib==0.3.2
distro-info===0.23ubuntu1
entrypoints==0.3
et-xmlfile==1.0.1
filelock==3.0.12
funcy==1.16
future==0.18.2
greenlet==1.1.1
html5lib==1.0.1
httpie==2.5.0
hyperopt==0.2.5
idna==3.2
importlib-metadata==1.5.0
ipaddress==1.0.23
ipykernel==6.4.0
ipython==7.27.0
ipython-genutils==0.2.0
ipywidgets==7.6.4
j2cli==0.3.10
jdcal==1.0
jedi==0.18.0
Jinja2==3.0.1
joblib==1.0.1
json-lines==0.5.0
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==7.0.2
jupyter-console==6.4.0
jupyter-core==4.7.1
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.1
kiwisolver==1.3.2
lxml==4.5.0
MarkupSafe==2.0.1
matplotlib==3.3.4
matplotlib-inline==0.1.3
mistune==0.8.4
more-itertools==4.2.0
nbclient==0.5.4
nbconvert==6.1.0
nbformat==5.1.3
nest-asyncio==1.5.1
networkx==2.6.3
notebook==6.4.3
numexpr==2.7.3
numpy==1.21.2
olefile==0.46
openpyxl==3.0.3
packaging==21.0
panda==0.3.1
pandas==0.24.2
pandasql==0.7.3
pandocfilters==1.4.3
parso==0.8.2
pbr==5.6.0
pexpect==4.8.0
pickleshare==0.7.5
Pillow==8.3.2
pkgconfig==1.5.5
platformdirs==2.3.0
pluggy==0.13.0
prometheus-client==0.11.0
prompt-toolkit==3.0.20
ptyprocess==0.7.0
py==1.8.1
pycparser==2.20
pydot==1.4.2
Pygments==2.10.0
PyGObject==3.36.0
pyLDAvis==3.2.2
pyparsing==2.4.7
pyrsistent==0.18.0
PySocks==1.7.1
pytest==4.6.9
python-apt==2.0.0+ubuntu0.20.4.6
python-dateutil==2.5.2
python-git==2018.2.1
pytz==2021.1
PyYAML==3.11
pyzmq==22.2.1
qtconsole==5.1.1
QtPy==1.11.0
requests==2.26.0
requests-toolbelt==0.9.1
requests-unixsocket==0.2.0
scikit-learn==0.24.2
scipy==1.7.1
seaborn==0.11.2
Send2Trash==1.8.0
six==1.16.0
soupsieve==1.9.5
SQLAlchemy==1.4.23
stevedore==3.4.0
tables==3.6.1
terminado==0.12.1
testpath==0.5.0
threadpoolctl==2.2.0
tornado==6.1
tqdm==4.62.2
traitlets==5.1.0
unattended-upgrades==0.1
urllib3==1.26.6
virtualenv==20.7.2
virtualenv-clone==0.5.7
virtualenvwrapper==4.8.4
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.5.1
xlrd==1.1.0
xlwt==1.3.0
yml2json==1.1.3
zipp==1.0.0