Dockerfile Installing Selenium - Ambiguous code - docker

Can someone explain this code to me?
# Installation required for selenium
RUN apt-get update -y \
&& apt-get install --no-install-recommends --no-install-suggests -y tzdata ca-certificates bzip2 curl wget libc-dev libxt6 \
&& apt-get install --no-install-recommends --no-install-suggests -y `apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` \
&& update-ca-certificates \
# Cleanup unnecessary stuff
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/* /tmp/*
Why is it necessary to put this in a Dockerfile for selenium to run? (tested and won't run without the code). Why doesn't it simply work by using pip to install the selenium dependency?
Source: Firefox(headless)+selenium cannot access internet from docker container

Related

Issue compiling Dockerfile on MacOS(apple Sillicon)

This is my first time to use Docker
I build a Dockerfile and use the Vscode remote container to open folder in Container.
When I run this Dockerfile on Windows 11. It does not have any problem
But When I run it on MacOS(apple Sillicon). It have error.
after I step by step to check the Dockerfile.
I find that if I install g++multilib or libc6-dev-i386, it will get error.
I do not have any idea about why?
Dockerfile:
FROM ubuntu:18.04
RUN apt update \
&& apt-get -y install gcc g++ python \
&& apt-get -y install python-dev \
&& apt-get -y install qt4-dev-tools libqt4-dev \
&& apt-get -y install mercurial \
&& apt-get -y install bzr \
&& apt-get -y install cmake libc6-dev \
&& apt-get -y install gdb valgrind \
&& apt-get -y install flex bison libfl-dev \
&& apt-get -y install tcpdump \
&& apt-get -y install sqlite sqlite3 libsqlite3-dev \
&& apt-get -y install gsl-bin libgslcblas0 \
&& apt-get -y install libxml2 libxml2-dev \
&& apt-get -y install libgtk2.0-0 libgtk2.0-dev \
&& apt-get -y install vtun lxc \
&& apt -y install git \
&& apt -y install npm \
&& apt-get -y install g++-multilib libc6-dev-i386
devcontainer.json:
{
"name": "802.11ah ns-3 simulation",
"dockerFile": "Dockerfile",
"appPort": 3000,
"extensions": ["dbaeumer.vscode-eslint"],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
}
}
error information: https://i.stack.imgur.com/ZE04I.jpg
You dont have specified the architetture of Ubuntu container in docker file. Apple silicon have ARM architecture, not all image are compatibile.

'DEBIAN_FRONTEND=noninteractive' not working inside shell script with apt-get

I'm buildinga a docker image using a Dockerfile to build it. I have put ARG DEBIAN_FRONTEND=noninteractive in the beginning of the Dockerfile to avoid debconf warnings while building.
The warnings does not show up when using apt-get install inside the Dockerfile. However when executing a sh script (install_dependencies.sh) from the Dockerfile that contains apt-get install commands, the warnings show up again. I also tried to set DEBIAN_FRONTEND=noninteractive inside the sh script itself.
I can solve this by adding echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections in the sh script before the apt-get install commands but I would want to avoid that, since any fail in the script would leave debconf select to Noninteractive.
Dockerfile:
FROM ubuntu:18.04
# Avoid warnings by switching to noninteractive
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /tmp
# Configure APT --> HERE THE WARNINGS 'debconf: unable to initialize frontend: Dialog' ARE NOT DISPLAYED
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y \
apt-utils \
dialog \
fakeroot \
software-properties-common \
2>&1
# Install APT packages --> HERE THE WARNINGS 'debconf: unable to initialize frontend: Dialog' ARE NOT DISPLAYED
RUN apt-get update && apt-get install -y \
#
# System packages
iproute2 \
procps \
lsb-release \
sudo \
unattended-upgrades \
dnsutils \
iputils-ping \
xauth \
openssl \
tar \
zip \
#
# Helpers
&& apt-get install -y \
ca-certificates \
curl \
wget \
lsof \
gconf2 \
gconf-service \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Install LTE stack dependencies --> HERE THE WARNINGS 'debconf: unable to initialize frontend: Dialog' ARE DISPLAYED
RUN chmod +x install_dependencies.sh \
&& export DEBIAN_FRONTEND=noninteractive; ./install_dependencies.sh
install_dependencies.sh:
#!/bin/sh
export DEBIAN_FRONTEND=noninteractive
APT_PACKAGES="lib32z1 \
python-setuptools \
libmysqlclient-dev \
ninja-build"
install_apt_packages() {
sudo apt-get install -y tzdata \
build-essential \
git
for package in $APT_PACKAGES;
do
sudo apt-get -y install "$package";
done
}
main() {
sudo apt-get update && sudo apt-get upgrade -y
install_apt_packages
}
main
EDIT: Thanks to #arkadiusz-drabczyk for telling me to remove sudo from the apt-get commands, it makes perfect sense what he says, that the environment variables drop before executing the command.
Drop sudo in your script, there is point to use it if you're running as root. This is also the reason that DEBIAN_FRONTEND has no effect - sudo drops your current user's environment for security reasons, you'd have to use with -E option to make it work.

Install libjpeg.so.8 Debian 11 inside Docker

I tried to integrate an application - QCPump - inside an existing Docker, with an other application - QAtrack+. The goal is to use QCPump inside QAtrack+.
The application code seems to be integrated but when I launch it, I have an error :
ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory
The error is raised by the wxPython package.
Okay, so I have to install it. Unfortunately, my Docker linux is Debian 11, and Debian seems to grab this package several years ago. So, after some reseach, I found that this package is "replaced" - for Debian - by libjpeg-dev. So, I did it. And same result ...
I found the code of the librairy (wxPython) and a docker part has done for Debian 10 : https://github.com/wxWidgets/Phoenix/blob/master/docker/build/debian-10/Dockerfile
I took this part and integrated it in my DockerFile :
RUN apt-get install -y \
freeglut3 \
freeglut3-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
libgstreamer-plugins-base1.0-dev \
libgtk-3-dev \
libjpeg-dev \
libnotify-dev \
libsdl2-dev \
libsm-dev \
libtiff-dev \
libwebkit2gtk-4.0-dev \
libxtst-dev; \
apt-get clean;
But same ...
In some forum, people mentionned the LD have to be update. I tried this way but I am not pretty sure :
RUN export LD_LIBRARY_PATH=/usr/local/lib
And to be honest, I am not sure this is the problem and so the solution here...
Any idea about this problem ?
Following, my complete DockerFile if you need it ;)
FROM python:3.6
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' > /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get update && apt-get install -y \
cron postgresql-client-10 cifs-utils dos2unix \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get install tzdata
ENV TZ 'Europe/Paris'
RUN dpkg-reconfigure -f noninteractive tzdata
RUN touch /root/.is_inside_docker
RUN pip install virtualenv
RUN date "+%H:%M:%S %d/%m/%y"
RUN apt-get -q update && \
apt-get install -yq chromium && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update -y && apt-get install -y libsdl2-ttf-2.0-0 && \
apt-get update -y && apt-get install -y libjpeg-dev libaio1 libaio-dev && \
wget -q -O /tmp/libpng12.deb http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/libpng12- 0_1.2.54-1ubuntu1_amd64.deb \
&& dpkg -i /tmp/libpng12.deb \
&& rm /tmp/libpng12.deb \
&& apt-get install -y \
freeglut3 \
freeglut3-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
libgstreamer-plugins-base1.0-dev \
libgtk-3-dev \
libjpeg-dev \
libnotify-dev \
libsdl2-dev \
libsm-dev \
libtiff-dev \
libwebkit2gtk-4.0-dev \
libxtst-dev; \
apt-get clean;
RUN export LD_LIBRARY_PATH=/usr/local/lib
WORKDIR /usr/src/qatrackplus

Dockerfile from python:3.6-slim add jdk8

someone could help me, i'm starting from follow docker file
FROM python:3.6-slim
RUN apt-get update
RUN apt-get install -y apt-utils build-essential gcc
And i would add an openjdk 8
thanks
You can download java tar.gz, unpack it and set environment variable.
Below a sample of implementation in Dockerfile:
FROM python:3.6-slim
RUN apt-get update
RUN apt-get install -y apt-utils build-essential gcc
ENV JAVA_FOLDER java-se-8u41-ri
ENV JVM_ROOT /usr/lib/jvm
ENV JAVA_PKG_NAME openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
ENV JAVA_TAR_GZ_URL https://download.java.net/openjdk/jdk8u41/ri/$JAVA_PKG_NAME
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
apt-get autoremove && \
echo Downloading $JAVA_TAR_GZ_URL && \
wget -q $JAVA_TAR_GZ_URL && \
tar -xvf $JAVA_PKG_NAME && \
rm $JAVA_PKG_NAME && \
mkdir -p /usr/lib/jvm && \
mv ./$JAVA_FOLDER $JVM_ROOT && \
update-alternatives --install /usr/bin/java java $JVM_ROOT/$JAVA_FOLDER/bin/java 1 && \
update-alternatives --install /usr/bin/javac javac $JVM_ROOT/$JAVA_FOLDER/bin/javac 1 && \
java -version
In cases where you need python and java installed in a same image (i.e. pyspark) I find it easier to extend the openjdk images with python than the other way around for example:
FROM openjdk:8-jdk-slim-buster
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
python3.7 \
python3-pip \
python3.7-dev \
python3-setuptools \
python3-wheel
Build the image: docker build --rm -t so:64051125 .
Note: the version of python3 available through apt on debian:buster-slim is 3.7, if you really need 3.6 could try building it from source.
Up to today (17/02/2021) openjdk-8-jdk is still in debian 9 (Strech) but removed from debian 10 (Buster), so you should find openjdk-8-jdk if you use this python docker image: python:3.6-stretch instead of python:3.6-slim-buster

error running Julia on Ubuntu 16.04 docker for host with GPU

I'm stuck in getting Julia to run on Ubuntu 16.04 on a server having GPUs. Basically we want to utilise power of GPUs.
We're using Docker image to host Julia, it's pulled from nvidia-cuda, the docker image is building successfully, but when I run julia with any switch e.g. julia -v or just julia, I'm getting error ERROR: Unable to find compatible target in system image. I tried finding hints online but no luck, hence posting question here.
After building docker image, I'm running using docker run command by mounting some shared folders, it's coming up successfully, but Julia doesn't seem to work. Please let me know what wrong am I doing here.
Following is Dockerfile code
FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
MAINTAINER comafire <comafire#gmail.com>
# Bash
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
USER root
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
apt-utils \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Lang
ARG locale="en_US.UTF-8"
ENV LOCALE ${locale}
RUN echo "LOCALE: $LOCALE"
RUN if [[ $LOCALE = *en* ]] \
; then \
apt-get update && apt-get install -y --no-install-recommends \
locales language-pack-en \
; else \
apt-get update && apt-get install -y --no-install-recommends \
locales language-pack-en \
; fi
RUN echo "$LOCALE UTF-8" > /etc/locale.gen && locale-gen
ENV LC_ALL ${LOCALE}
ENV LANG ${LOCALE}
ENV LANGUAGE ${LOCALE}
ENV LC_MESSAGES POSIX
# Common
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential vim curl wget git cmake bzip2 sudo unzip net-tools \
libffi-dev libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm \
libfreetype6-dev libxft-dev
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common libjpeg-dev libpng-dev ncurses-dev imagemagick \
libgraphicsmagick1-dev libzmq-dev gfortran gnuplot gnuplot-x11 libsdl2-dev \
openssh-client htop iputils-ping
# Python2
RUN apt-get update && apt-get install -y --no-install-recommends \
python python-dev python-pip python-virtualenv python-software-properties
RUN pip2 install --upgrade pip
RUN pip2 install --cache-dir /tmp/pip2 --upgrade setuptools wheel
# Python3
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-dev python3-pip python3-virtualenv python3-software-properties
RUN pip3 install --upgrade pip
RUN pip3 install --cache-dir /tmp/pip3 --upgrade setuptools wheel
# Julia
ENV JULIA_VERSION 1.0.2
RUN apt-get update && apt-get install -y build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config
RUN cd /usr/local && git clone git://github.com/JuliaLang/julia.git && cd julia && git checkout v${JULIA_VERSION}
#RUN make -C deps distclean-llvm && make
RUN cd /usr/local/julia && make -j4
RUN sudo ln -s /usr/local/julia/usr/bin/julia /usr/local/bin/julia
RUN /usr/local/julia/usr/bin/julia -v
RUN ls -al /usr/local/bin
RUN julia -v
WORKDIR /tmp
COPY packages.jl ./
RUN julia packages.jl
When executing RUN julia is julia already in your $PATH? Try executing julia directly, for example:
RUN chmod +x /path/to/julia
RUN /path/to/julia

Resources