Docker: Openjdk:14 RHEL based imaged, cannot install yum/wget/netstat - docker

In my dockerfile, I need a maven builder (3.6 at least) working on a OpenJDK (J14 is required).
FROM maven:3.6.3-openjdk-14 as builder
The problem is simple: I need netstat command because it is used in several scripts. The OpenJDK official image is RHEL based, so it comes without any of this package installed.
I tried to download it or yum via wget command but, as you can guess, it is not installed. I feel trapped because it seems like you cannot you can't install any package on it.

That image is actually based on Oracle
$ podman run -it maven:3.6.3-openjdk-14 /bin/bash -c 'cat /etc/os-release'
NAME="Oracle Linux Server"
VERSION="8.2"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.2"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.2"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:2: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.2
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.2
And this is actually a "slim" variant where dnf or yum aren't installed, but microdnf is. Try using that, instead:
RUN microdnf install /usr/bin/netstat
Or
RUN microdnf install net-tools

Related

Install valgrind on ubi8-minimal docker image

I want to install valgrind on a docker container based on ubi-8 minimal image. The problem is the tool doesn't seem to be available in any packages on the microdnf repository. I tried with gcc-toolset-11-valgrind, gcc-toolset-11-gcc-11, gcc-toolset-11-gcc-c++, gcc-toolset-11-runtime, etc to see if the tool is available in any package. There should be a package available for normal rpm: gcc-toolset-11-perftools, but it isn't available.
I also tried to download valgrind by hand and execute from a volume but the dependencies are not available. Is there a easier way to get running valgrind on a ubi8-minimal docker container?
Using rpm in combination with already download packages I finally managed to install valgrind, the process was:
download valgrind package and dependencies with yum in the host machine
yum install --downloadonly --downloaddir=./valgrindDownload gcc-toolset-11-valgrind
Find out missing dependencies (gcc-toolset-11-runtime-11, and perl)
Install local packages using rpm:
rpm --install ./valgrindDownload/gcc-toolset-11-valgrind-3.17.0-6.el8.x86_64.rpm
Find out valgrind instalation directory
In my case was under /opt/rh/gcc-toolset-11/root/usr/bin/valgrind
Finally run the full command:
sudo docker run -v `pwd`:/home/<container-dir> <docker-image>:<version> /bin/bash -c "microdnf install gcc-toolset-11-runtime-11.1-1.el8.x86_64 && microdnf install perl-5.26.3-421.el8.x86_64 && rpm --install ./valgrindDownload/gcc-toolset-11-valgrind-3.17.0-6.el8.x86_64.rpm && /opt/rh/gcc-toolset-11/root/usr/bin/valgrind --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt command <arguments>"
Doing so, the valgrind output gets redirected to valgrind-out.txt

rustembedded/cross- can't override linux image

I'm attempting to use rustembedded/cross to cross compile to linux but I need to override the default image since I need clang and the default image doesn't provide that.
According to their documentation, you can provide a dockerfile and a configuration file to accomplish this.
This led me to having a docker file of:
FROM rustembedded/cross:x86_64-unknown-linux-gnu
RUN dpkg --add-architecture x86_64 && apt-get update && \
apt-get install --assume-yes --no-install-recommends \
libclang-dev \
clang
and a Cross.toml configuration file of:
[target.x86_64-unknown-linux-gnu]
image = "linux:v2"
Then, when I build this image with docker build -f ./Dockerfile.x86_64-unknown-linux-gnu -t linux:v2 ., it gives me an error saying that dkpg can't be found. Even if I remove that part it tells me that apt-get can't be found.
I can access the shell of the container that it extends, rustembedded/cross:x86_64-unknown-linux-gnu, in docker desktop and if I run dpkg, it shows me the help command. This is confusing since my image extends from it but it doesn't know about dkpg.
rustembedded/cross:x86_64-unknown-linux-gnu is based on centos, not ubuntu, see its Dockerfile:
FROM ubuntu:16.04
COPY linux-image.sh /
RUN /linux-image.sh x86_64
FROM centos:7
It use multistage build, the last os is centos:7.
You could also confirm it with next:
$ docker run --rm -it rustembedded/cross:x86_64-unknown-linux-gnu cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
I don't know how you get dpkg with manual run, definitely something wrong with your steps. But the package system in centos is yum, you should find same ways using yum for your package install.
$ docker run --rm -it rustembedded/cross:x86_64-unknown-linux-gnu yum version
Loaded plugins: fastestmirror, ovl
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Installed: 7/x86_64 213:96cbf4a3c83d0362309d530d515684dce3f40f63
Group-Installed: yum 14:302aa408884b4b89361d6bb1c41ceac40665f80e
version

How to make both javac and java on my path in ubuntu 16.04 LTS

I need to make both javac and java on my path.
I used the commands I got from other sites
$ sudo apt-get install default-jre
$ sudo apt-get install default-jdk
$ java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
$ which java
/usr/bin/java
$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.
Now provided all of these information, how can I set the path? I am comfortable using vi ~/.bashrc. So please guide me step by step for the setup. I found other posts very confusing.
sudo vim .bashrc
(Check this path "/usr/lib/jvm/java-8-oracle" if jvm installed their)
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export PATH=$PATH:$JAVA_HOME/bin
save it.
run
bash
or
source .bashrc

docker Error with pre-create check: "We support Virtualbox starting with version 5

I'm trying to create docker machine host using the following command in fedora OS version 25.
docker-machine create -driver=virtualbox host01
I get below error while executing the command.
Error with pre-create check: "We support Virtualbox starting with version 5. Your VirtualBox install is \"WARNING:
The vboxdrv kernel module is not loaded.
Either there is no module available for the current kernel (4.10.12-200.fc25.x86_64) or it failed to load.
Please try load the kernel module by executing as root
dnf install akmod-VirtualBox kernel-devel-4.10.12-200.fc25.x86_64 akmods --kernels 4.10.12-200.fc25.x86_64 && systemctl restart systemd-modules-load.service
You will not be able to start VMs until this problem is fixed.\\n5.1.26r117224\".
Please upgrade at https://www.virtualbox.org"
I have already virtualbox latest version installed. Running the command suggested by
sudo dnf install akmod-VirtualBox kernel-devel-4.10.12-200.fc25.x86_64 akmods --kernels 4.10.12-200.fc25.x86_64 && systemctl restart systemd-modules-load.service
I got the below error
Last metadata expiration check: 0:48:35 ago on Thu Aug 17 22:38:47 2017.
Package akmods-0.5.6-7.fc25.noarch is already installed, skipping.
No package --kernels available.
No package 4.10.12-200.fc25.x86_64 available.
Any suggestions?
I also had this problem and for this I upgrade Virtual box to 5.2 using following commands. This link help me
sudo apt-get remove virtualbox virtualbox-5.1
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian xenial contrib" >> /etc/apt/sources.list.d/virtualbox.list'
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install virtualbox-5.2
Hope this helps.
For windows users, in 2022 such problem still exists. So for those who use last build (now it is virtualBox-6.1.32-149290-Win), try to use version that starts with prefix 5. But not all '5' versions work. For example, for me worked only version 5.2.42 while versions: 5.2.18, 5.2.20, 5.2.44 didn't work
Helped for win 11 x64

What is the docker daemon version on Vagrant provisioner?

I am trying to understand which is the version that Vagrant installs on its VM (my specific case: using box ubuntu/trusty64) if a Docker provisioner is selected.
In particular, I would like it to be a fixed version since it has to reflect my staging environment.
Unfortunately, in the documentation of the provisioner nothing is mentioned about which version of the Docker daemon will be installed. Same by searching for my question, either on google or on github issues.
Can somebody point me to the right directions/docs?
Basically vagrant will try to install the latest version available from the repo. You can review in the source code
machine.communicate.tap do |comm|
comm.sudo("apt-get update -qq -y")
comm.sudo("apt-get install -qq -y --force-yes curl apt-transport-https")
comm.sudo("apt-get purge -qq -y lxc-docker* || true")
comm.sudo("curl -sSL https://get.docker.com/ | sh")
end
If you prefer to have a specific version installed you would need to run a shell provisioner before your docker provisioner (provisioner are run in order) and install the version you want to work with

Resources