How to install standard system commands for amazon-linux 2 - docker

I seem to be missing some very basic utilities, namely the commands sudo and which seem to be missing. How can I install these, or even better is there an ami linux image which has all of these kind of things pre-installed.
Dockerfile:
FROM amazonlinux:2.0.20190823.1-with-sources
RUN echo $(which sudo)
Error:
/bin/sh: which: command not found
Or if I just try to use something like sudo yum
/bin/sh: sudo: command not found
Since it seems relevant, I also don't seem to have root permissions as trying to use the adduser command gives me a non zero response code of 2.

RUN yum update && yum install -y sudo, sudo is not installed in that image by default. you are already root in that images so you do not need sudo yum.
the idea from not installing too many packages by default ,is to let the image as small as possible and let the user install just what he needs

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

Cannot uninstall Podman from CentOS 8

I have podman installed on a CentOS 8 machine. I want to switch to Docker so need to remove podman first because it conflicts with Docker.
However, when I try to remove it I get this:
Error:
Problem: The operation would result in removing the following protected packages: dnf, systemd, systemd-udev
Tried this and it didn't work:
https://www.ibm.com/docs/en/eam/4.2?topic=questions-troubleshooting-tips#uninstall_podman
buildah is not even installed
Tried with both yum and dnf - no go
solved by adding --allowerasing
sudo yum install docker-ce.x86_64 --allowerasing

Can't find any man pages in Fedora Docker Image

After installing the man pages via dnf, I still can't find them inside /usr/share/man.
docker run --rm -it fedora bash -c "dnf install -y man-pages && ls -lR /usr/share/man"
Did I miss something?
The default configuration for the docker version of fedora disable the installation of documentation.
cat /etc/dnf/dnf.conf
Check out the last line :
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=False
skip_if_unavailable=True
tsflags=nodocs
However, it is still possible to change the last line or override it like below command :
dnf install -y man-pages --setopt='tsflags='
I would liked to contribute as I was looking for the answer and I found the answer, from the link here
Confirm the below line is removed from /etc/dnf/dnf.conf
tsflags=nodocs
and remove and reinstall the man pages using dnf
dnf install man man-pages man-db

Is there any way to run "pkexec" from a docker container?

I am trying to set up a Docker image (my Dockerfile is available here, sorry for the french README: https://framagit.org/Gwendal/firefox-icedtea-docker) with an old version of Firefox and an old version of Java to run an old Java applet to start a VPN. My image does work and successfully allows me to start the Java applet in Firefox.
Unfortunately, the said applet then tries to run the following command in the container (I've simply removed the --config part from the command as it does not matter here):
INFO: launching '/usr/bin/pkexec sh -c /usr/sbin/openvpn --config ...'
Then the applet exits silently with an error. While investigating, I've tried running a command with pkexec with the same Docker image, and it gives me this result:
$ sudo docker-compose run firefox pkexec /firefox/firefox-sdk/bin/firefox-bin -new-instance
**
ERROR:pkexec.c:719:main: assertion failed: (polkit_unix_process_get_start_time (POLKIT_UNIX_PROCESS (subject)) > 0)
But I don't know polkit at all and cannot understand this error.
EDIT: A more minimal way to reproduce the problem is with this Dockerfile:
FROM ubuntu:16.04
RUN apt-get update \
&& apt-get install -y policykit-1
And then run:
$ sudo docker build -t pkexec-test .
$ sudo docker run pkexec-test pkexec echo Hello
Which leads here again to:
ERROR:pkexec.c:719:main: assertion failed: (polkit_unix_process_get_start_time (POLKIT_UNIX_PROCESS (subject)) > 0)
Should I conclude that pkexec cannot work in a docker container? Or is there any way to make this command work?
Sidenote: I have no control whatsoever on the Java applet that I try to run, it is a horrible and very dated proprietary black box that I am supposed to use at work, for which I have no access to the source code, and that I must use as is.
I have solved my own problem by replacing pkexec by sudo in the docker image, and by allowing passwordless sudo.
Given an ubuntu docker image where a user called developer was created and configured with a USER statement, add these lines:
# Install sudo and make 'developer' a passwordless sudoer
RUN apt-get install sudo
ADD ./developersudo /etc/sudoers.d/developersudo
# Replacing pkexec by sudo
RUN rm /usr/bin/pkexec
RUN ln -s /usr/bin/sudo /usr/bin/pkexec
with the file developersudo containing:
developer ALL=(ALL) NOPASSWD:ALL
This replaces any call to pkexec made in a process running in the container, by a call to sudo without any password prompt, which works nicely.

MediaWiki Scribunto Lua error: Internal error: The interpreter exited with status 2

I have done a fresh installation on my local development machine of MediaWiki 1.24.2.
I have installed Scribunto and checked it is installed correctly on the list of extensions.
I'm getting an error when I try and create an InfoBox. The error is:
Lua error: Internal error: The interpreter exited with status 2
These are the steps I have taken the following steps to try and fix this.
I have been to the Mediawiki Scribunto page
I have added these lines to my LocalSettings.php file:
$wgScribuntoEngineConf['luastandalone']['memoryLimit'] = 209715200; # bytes
$wgMaxShellMemory = 204800; # in KB
This has not fixed things. I'm a but confused as to how to switch on error logging. The help page just says:
Assigning a file path to $wgScribuntoEngineConf['luastandalone']['errorFile'] and examining that output can be valuable in diagnosing memory allocation errors.
How do I assign a file path? - Solved Thanks for the help with this.
I enclose a [link][2] to my php.ini file and my LocalSettings.php file (Zipped together)
UPDATE - I have now managed to add a log file and the error in the log file is:
/var/www/extensions/Scribunto/engines/LuaStandalone/binaries/lua5_1_5_linux_32_generic/lua: Syntax error: "(" unexpected
UPDATE TWO
These are the full steps I take to replicate the error:
Start by checking for any package updates available and installing them
sudo apt-get update
sudo apt-get upgrade
Now install Apache, PHP and MySQL
sudo apt-get install apache2 -y
sudo apt-get install php5 libapache2-mod-php5 -y
sudo apt-get install mysql-server php5-mysql -y
sudo apt-get install php-apc php5-intl imagemagick
sudo apt-get install phpmyadmin
We can check the internal IP address of our Raspberry Pi with the following command (Make a note of it)
hostname -I
We can now create a database for our new MediaWIki installation. Start by logging in as root using the password you created earlier
mysql -u root -p
Here we are adding database=mediawikidb user=mediawikiuser and password=mediawikipassword:
CREATE DATABASE mediawikidb;
CREATE USER mediawikiuser#localhost IDENTIFIED BY 'mediawikipassword';
GRANT index, create, select, insert, update, delete, alter, lock tables on mediawikidb.* TO mediawikiuser#localhost;
Now we can make some changes to php.ini so we can increase the maximum file size and memory limit
cd /etc/php5/apache2/
nano php.ini
Replace 'upload_max_filesize = 2M' with 'upload_max_filesize = 64M'
Replace 'post_max_size = 8M' with 'post_max_size = 64M'
Save the file
Now we are going to empty the /var/www folder and change its ownership to pi
cd /var/www
sudo chown pi: .
sudo rm *
Now we can download MediaWiki, uncompress it and copy it into /var/www
mkdir /var/www/mediawiki
wget http://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.2.tar.gz
tar -xvzf mediawiki-*.tar.gz
sudo mv mediawiki-*/* /var/www/
Now we can restart the relevant services
sudo service apache2 restart
sudo service mysql restart
Now open a browser and go to localhost and start the installation
To Complete Installation copy LocalSettings.php to /var/www/mediawiki
Now install Scribunto
Download from http://www.mediawiki.org/wiki/Special:ExtensionDistributor/Scribunto
tar -xzf Scribunto-REL1_24-b060fbd.tar.gz -C /var/www/mediawiki/extensions
sudo nano /etc/mediawiki/LocalSettings.php
add these lines at the end of the file and save
require_once "$IP/extensions/Scribunto/Scribunto.php";
$wgScribuntoDefaultEngine = 'luastandalone';
$wgScribuntoEngineConf['luastandalone']['memoryLimit'] = 209715200; # bytes
$wgMaxShellMemory = 204800; # in KB
$wgScribuntoEngineConf['luastandalone']['errorFile'] = '/var/tmp/luaerror.log';
chmod -R 777 /var/www/mediawiki/extentions/Scribunto/engines/LuaStandalone/
Now visit 'http://en.wikipedia.org/wiki/Special:Export' and enter Template:Infobox in the big box. Tick all three boxes and click Export
Open the file in Notepad or similar and do a find and replace text/plain with CONTENT_FORMAT_TEXT
Login to MediaWiki and go to Special:Import
Once everything has imported correctly go to the homepage and enter this at the top of the page:
{{Infobox
|title = test Infobox
|header1 = Main Heading
|header2 = First set of data
|label2 = Label
|data2 = Data
|header3 = Remove this line (optional)
|label3 = More Label
|data3 = More data
}}
Many thanks
Finally fixed. I did:
sudo apt-get install lua
Then added the following to my LocalSettings.php
$wgScribuntoEngineConf['luastandalone']['luaPath'] = '/usr/bin/lua5.1';
I assume the lua binary included with Scribunto is not ok with the Raspberry Pi?

Resources