How to install a PostgreSQL terminal client using microdnf install? - linux

What PostgreSQL clients are available through microdnf install?
I'm trying to install a client via my Dockerfile.
I've tried multiple commands I've seen recommended and several guesses, but none of them worked for me:
microdnf install -y postgresql-client
microdnf install -y postgresql
microdnf install -y psql
etc.
Image being used:
https://hub.docker.com/r/jboss/keycloak/
sh-4.4$ cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.3 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.3"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.3 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.3:GA"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.3
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.3"
PS = Is there a website I can go to to see the full list of packages available?

I have the same issue, but with maven docker image (it based on OracleLinux 8).
Oracle Linux 8 & Postgresql13 Client
It was extremely unusual to install postgresql client on it, so, let's consider my steps:
https://www.postgresql.org/download/linux/redhat/
Select RHEL 8 and receive the rpm package link
Install it manually with rpm
microdnf install -y wget
wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm -O /tmp/pg_repo.rpm
rpm -i /tmp/pg_repo.rpm
Determine that there is no postgresql13 package. Click on the direct download link and select RHEL 8: https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/
Download postgresql13-13.x.x... package (latest)
wget https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/postgresql13-13.3-2PGDG.rhel8.x86_64.rpm -O /tmp/pgql.rpm
Dependency list for that rpm:
libicu is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
libpq.so.5()(64bit) is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
postgresql13-libs(x86-64) = 13.3-2PGDG.rhel8 is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
systemd is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
systemd-sysv is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
Install dependencies
microdnf install -y systemd postgresql13-libs libicu
Finally, install the client
rpm -i /tmp/pgql.rpm
Now you can clear the cache and test the client, e.g. pg_dump command.
Result Dockerfile command:
RUN microdnf install -y wget && \
wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm -O /tmp/pg_repo.rpm && \
rpm -i /tmp/pg_repo.rpm && \
microdnf install -y systemd postgresql13-libs libicu && \
wget https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/postgresql13-13.3-2PGDG.rhel8.x86_64.rpm -O /tmp/pgql.rpm && \
rpm -i /tmp/pgql.rpm && \
rm -f /tmp/pg_repo.rpm /tmp/pgql.rpm && \
microdnf remove -y wget
RHEL 8 & Postgresql13 Client (your case)
Now let's consider your case, image jboss/keycloak:14.0.0 based on RHEL 8.
Caveat: If you receive error message error: Failed to create: /var/cache/yum/metadata, run as root user and than switch user back to jboss.
All steps and Dockerfile commands are the same.
Please, let me know if there are any mistakes or something is not well-described.

It's working for me on with a Dockerfile based on openjdk:15.
FROM openjdk:15.0.1-oracle
...
RUN microdnf update
RUN microdnf module enable postgresql:13
RUN microdnf install postgresql.x86_64

Related

How to add user and a group in Docker Container running Macosx

I have a Docker container running "FROM arm64v8/oraclelinux:8" , I am running this on a Mac m1 mini using tightvnc.
I want to add a user called "suiteuser" (uid 42065) and in a group called "cvsgroup" (gid 513), inside my docker container, So that when I run the container it starts under my user directly.
Here is my entire Dockerfile-
FROM arm64v8/oraclelinux:8
# Setup basic environment stuff
ENV container docker
ENV LANG en_US.UTF-8
ENV TZ EST
ENV DEBIAN_FRONTEND=noninteractive
# Base image stuff
#RUN yum install -y zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel vim yum-utils sssd sssd-tools krb5-libs krb5-workstation.x86_64
# CCSMP dependent
RUN yum install -y wget
RUN yum install -y openssl-libs-1.1.1g-15.el8_3.aarch64
RUN yum install -y krb5-workstation krb5-libs krb5-devel
RUN yum install -y glibc-devel glibc-common
RUN yum install -y make gcc java-1.8.0-openjdk-devel tar perl maven svn openssl-devel gcc
RUN yum install -y gdb
RUN yum install -y openldap* openldap-clients nss-pam-ldapd
RUN yum install -y zlib-devel bzip2 bzip2-devel vim yum-utils sssd sssd-tools
# Minor changes to image to get ccsmp to build
RUN ln -s /usr/lib/jvm/java-1.8.0-openjdk /usr/lib/jvm/default-jvm
RUN cp /usr/include/linux/stddef.h /usr/include/stddef.h
# Install ant 1.10.12
RUN wget https://mirror.its.dal.ca/apache//ant/binaries/apache-ant-1.10.12-bin.zip
RUN unzip apache-ant-1.10.12-bin.zip && mv apache-ant-1.10.12/ /opt/ant
ENV JAVA_HOME /usr
ENV ANT_HOME="/usr/bin/ant"
ENV PATH="/usr/bin/ant:$PATH"
CMD /bin/bash
could anyone please suggest any ideas on how to do this.
Note 1. I know its not advisable to do this directly in the container as, every time you want to make any changes you would have to rebuild it, but this time i want to do this.
To create the group:
RUN groupadd -g 513 cvsgroup
To create the user, as a member of that group:
RUN useradd -G cvsgroup -m -u 42065 suiteuser
And toward the end of Dockerfile, you can set the user:
USER suiteuser
There may be more to do here, though, depending on your application. For example, you may need to chown some of the contents to be owned by suiteuser.

docker ERROR: Could not find a version that satisfies the requirement apturl==0.5.2

I am using windows 10 OS. I want to build an container based on linux so I can replicate code and dependencies developed from ubuntu. When I try to build it outputs Error message as above.
From my understanding docker for desktop runs linux OS kernel under-the-hood therefore allowing window users to run linux based containers, not sure why it is outputting this error.
My dockerfile looks like this:
FROM ubuntu:18.04
ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"
RUN apt update \
&& apt install -y htop python3-dev wget
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir root/.conda \
&& sh Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh
RUN conda create -y -n ml python=3.7
COPY . src/
RUN /bin/bash -c "cd src \
&& source activate ml \
&& pip install -r requirements.txt"
requirements.txt contains:
apturl==0.5.2
asn1crypto==0.24.0
bleach==2.1.2
Brlapi==0.6.6
certifi==2020.11.8
chardet==3.0.4
click==7.1.2
command-not-found==0.3
configparser==5.0.1
cryptography==2.1.4
cupshelpers==1.0
dataclasses==0.7
When I run docker build command it outputs:
1.649 ERROR: Could not find a version that satisfies the requirement apturl==0.5.2 1.649 ERROR: No matching distribution found for apturl==0.5.2 Deleting it and running it lead to another error. All error seem to be associated with ubuntu packages.
Am I not running a ubuntu container? why aren't I allowed to install ubuntu packages?
Thanks!
You try to install ubuntu packages with pip (which is for python packages")
try apt install -y apturl
If you want to install python packages write pip install package_name

Unable to find libssl.so.1.0.2 and libssl.so.1.0.2 when trying to use PyODBC on a Docker image

I have a docker file which uses python:3 (based on debian). I am installing the drivers for PyODBC as per the microsoft docs.
FROM python:3
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install msodbcsql17 unixodbc-dev -y
I can build the image, but when trying to run it I get the error: Can't open lib /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1
I have ran: ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1 and get the output that says the below two libs cannot be found:
libcrypto.so.1.0.2 => not found
libssl.so.1.0.2 => not found
I have also tried dpkg --search libssl and dpkg --search libsslcrypto which yielded:
libssl1.1:amd64: /usr/lib/x86_64-linux-gnu/libssl.so.1.1
libssl1.1:amd64: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
From ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1 there are other libraries being picked up in /usr/lib/x86_64-linux-gnu/
Very new to docker/linux, so how can I install libcrypto.so.1.0.2 and libssl.so.1.0.2 or downgrade the versions in '/usr/lib/x86_64-linux-gnu/' so that they can be used for msodbcsql17 (have tried apt get -y install libssl1.0=1.0.2) ?
The docker image python:3 appears to be built on Debian 10.
The package repository you are installing appears to be built for Debian 9, and does not appear to be compatible with Debian 10.
You should probably be using the repository with packages built for Debian 10 to get compatible packages.

How to refresh your shell when using a Dockerfile?

I am trying to build a Dockerfile that can make use of Azure functions. After unsuccessfully trying to build it using alpine:3.9 because of library issues, I swapped to ubuntu:18.04. Now I have a problem in that I can't install nvm (node version manager) in such a way that I can install node. My Dockerfile is below. I have managed to install nvm but now, while trying to use nvm, I cannot install the node version I want. The problem probably has to do with refreshing the shell but that is tricky to do as it appears that Docker continues to use the original shell it entered to run the next build stages. Any suggestions on how to refresh the shell so nvm can work effectively?
FROM ubuntu:18.04
RUN apt update && apt upgrade -y && apt install -qq -y --no-install-recommends \
python-pip \
python-setuptools \
wget \
build-essential \
libssl-dev
RUN pip install azure-cli
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
RUN . /root/.nvm/nvm.sh && nvm install 10.14.1 && node
ENTRYPOINT ["/bin/bash"]
After install nvm command put:
SHELL ["/bin/bash", "--login" , "-c"]
RUN nvm install 17
SHELL ["/bin/sh", "-c"]
Default shell is sh and first command switches it to bash. Parameter --login is required as you want to source .bashrc.
As all subsequent commands would be executed with changed shell it's good to switch it back to sh if you don't need it anymore.
You usually don't need version managers like nvm in a Docker image. Since a Docker image packages only a single application, and since it has its own isolated filesystem, you can just install the single version of Node you need.
The first thing I'd try is to just install whatever version of Node the standard Ubuntu package has (in Ubuntu 18.04, looks like 8.11). While there are some changes between Node versions, for the most part the language and core library have been pretty stable.
RUN apt update && apt-install nodejs
Or, if you need something newer, there are official Debian packages:
RUN curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_10.x cosmic main" > /etc/apt/sources.list.d/nodesource.list \
&& apt update \
&& apt install nodejs
This will give you a current version of that major version of Node (as of this writing, 10.15.1).
If you really need that specific version of Node, there are official binary packages. I might write:
FROM ubuntu:18.04
ARG node_version=10.14.1
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends --assume-yes \
ca-certificates \
curl \
xz-utils
RUN cd /usr/local \
&& curl -o- https://nodejs.org/dist/v${node_version}/node-v${node_version}-linux-x64.tar.xz \
| tar xJf - --strip 1
...where the last couple of lines unpack the Node tarball directly into /usr/local.

Install Yarn Ubuntu 16.04 (Linux Mint 18.1)

I have a new installation of Linux Mint 18.1 with Ubuntu 16.04.
I have installed Node 6.10.0.
When doing the command that indicates the documentation of Yarn:
sudo apt-get update && sudo apt-get install yarn
It says "could not find yarn package"
I must do something else, because in the documentation I do not see anything about it.
Thank you.
On Ubuntu Linux, you can install Yarn via Debian package repository. You will first need to configure the repository:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Then you can simply:
sudo apt-get update && sudo apt-get install yarn
More information here
I was unable to install Yarn on Ubuntu 16.04 using the accepted answer but found it easy with npm:
npm install -g yarn
Then check install / version with
yarn --version
See on Installation | Yarn | Linux tab
There are instructions for several linux distributions
Here are more details about the official install instruction.
apt-key command gets the public authentication key for software integration check.
deb https://dl.yarnpkg.com/debian/ stable main is the Ubuntu repository containing yarn. Look at OP's screenshot, the top 10 lines list existing repositories to search for packages, but there is no yarn's one. So we need to add the repository by creating file /etc/apt/sources.list.d/yarn.list.
After the above two steps, issue apt/apt-get command to add yarn like usual Ubuntu packages.
Be careful when using &&. I get the same error when running sudo apt-get update, which prevents terminal from running sudo apt-get install yarn. I was able to successfully install yarn on Ubuntu 16.04 by running these commands separately (without using &&)
In Ubuntu or Linux you can install yarn using terminal ,But before installing You will first need to configure the repository, for that run the below commands
sudo apt install curl
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
after setting up the repository you can simply install yarn using below command
sudo apt-get update && sudo apt-get install yarn
Once the installation gets completed you can check the version using following command
yarn --version
for more details go to yarn documentation

Resources