Jupyterlab docker container error on starting the container - python-3.x

I have created a notebook Docker file as below to running the JupyterHub and JupyterLab
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install sudo
RUN sudo useradd -m admin
RUN sudo echo -e "admin\nadmin\n" | passwd admin
RUN sudo echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER admin
RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends apt-utils
RUN sudo apt-get update \
&& sudo apt-get install -y build-essential \
&& sudo apt-get install -y libffi-dev \
&& sudo apt-get install -y libmysqlclient-dev \
&& sudo apt-get install -y libsasl2-dev \
&& sudo apt-get install -y openjdk-8-jdk \
&& sudo apt-get install -y openssh-server \
&& sudo apt-get install -y python-dev \
&& sudo apt-get install -y unzip \
&& sudo apt-get install -y wget \
&& sudo apt-get install -y mysql-client \
&& sudo apt-get install -y git
RUN sudo apt-get install -y libssl-dev libxml2-dev libxslt1-dev zlib1g-dev libkrb5-dev
RUN sudo apt-get update
RUN sudo apt-get install -y python3-pip
RUN sudo apt-get install -y python-pip
RUN sudo apt-get install -y python3-venv
RUN sudo python3 -m venv /opt/jupyterhub/
RUN sudo /opt/jupyterhub/bin/python3 -m pip install --upgrade pip
RUN sudo /opt/jupyterhub/bin/python3 -m pip install wheel
RUN sudo /opt/jupyterhub/bin/python3 -m pip install jupyterhub jupyterlab
RUN sudo /opt/jupyterhub/bin/python3 -m pip install ipywidgets
RUN sudo apt-get install -y curl
RUN sudo apt-get install -y nodejs npm
RUN sudo curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
RUN sudo bash nodesource_setup.sh
RUN sudo apt-get install -y nodejs
RUN sudo npm install -g -y configurable-http-proxy
RUN sudo mkdir -p /opt/jupyterhub/etc/jupyterhub/
RUN cd /opt/jupyterhub/etc/jupyterhub/
RUN sudo /opt/jupyterhub/bin/jupyterhub --generate-config
RUN sudo mkdir -p /opt/jupyterhub/etc/systemd
RUN sudo chown -R admin:admin /opt/jupyterhub
RUN sudo echo "c.Spawner.default_url = '/lab' " >> /opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py
RUN sudo echo "c.Authenticator.admin_users = {'admin'} " >> /opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py
RUN sudo echo "c.LocalAuthenticator.create_system_users=True" >> /opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py
RUN sudo echo -e '[Unit]\nDescription=JupyterHub\nAfter=syslog.target network.target\n\n[Service]\nUser=root\nEnvironment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/jupyterhub/bin"\nExecStart=/opt/jupyterhub/bin/jupyterhub -f /opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py\n\n[Install]\nWantedBy=multi-user.target' >> /opt/jupyterhub/etc/systemd/jupyterhub.service
RUN sudo cp /opt/jupyterhub/etc/systemd/jupyterhub.service /etc/systemd/system/jupyterhub.service
RUN sudo systemctl enable jupyterhub.service
#RUN sudo chown -R admin:admin /home/admin/.cache/pip
RUN sudo /opt/jupyterhub/bin/python3 -m pip install --upgrade setuptools
RUN sudo /opt/jupyterhub/bin/python3 -m pip install ipython==3.2.3
RUN sudo /opt/jupyterhub/bin/python3 -m pip install zipp==1.2.0
RUN sudo /opt/jupyterhub/bin/python3 -m pip install git+https://github.com/as-sher/sparkmagic.git#subdirectory=sparkmagic
RUN sudo /opt/jupyterhub/bin/jupyter-kernelspec install /opt/jupyterhub/lib/python3.5/site-packages/sparkmagic/kernels/sparkkernel
RUN sudo /opt/jupyterhub/bin/jupyter-kernelspec install /opt/jupyterhub/lib/python3.5/site-packages/sparkmagic/kernels/pysparkkernel
RUN sudo sed -i 's|root:x:0:0:root:/root:/bin/bash|root:x:0:0:root:/root:/sbin/nolgin|g' /etc/passwd
WORKDIR /home/admin
#USER root
EXPOSE 8000 2222
CMD SUDO SYSTEMCTL START JUPYTERHUB.SERVICE
When I am running this container as a root user, it is working, but when I am running this with admin (sudo user), I am getting the following error
Failed to mount tmpfs at /run/lock: Operation not permitted
[!!!!!!] Failed to mount API filesystems, freezing.
Freezing execution.
So my concern is that I have to run this container on Kubernetes and I don't want to run it as a root user and with privileged flag.
Is there any way in which I can run the existing docker with non-root user or if we can run the jupyter service without adding systemd.

There are some ways you can try in order to run Docker as a non-root user.
Manage Docker as a non-root user:
If you don’t want to preface the docker command with sudo, create a
Unix group called docker and add users to it. When the Docker daemon
starts, it creates a Unix socket accessible by members of the docker
group.
Create a docker group if there isn’t one:
$ sudo groupadd docker
Add your user to the docker group:
$ sudo usermod -aG docker [non-root user]
Log out and log back in so that your group membership is re-evaluated.
Run the Docker daemon as a non-root user (Rootless mode):
Rootless mode allows running the Docker daemon and containers as a
non-root user to mitigate potential vulnerabilities in the daemon and
the container runtime. Rootless mode does not require root privileges
even during the installation of the Docker daemon, as long as the
prerequisites are met.
Notice however that the second option is currently available as an experimental feature. You can find all the necessary details in the linked docs.
Please let me know if that helped.

Related

Chromedriver Installation using Docker file but the chrome driver does not reflect in the mentioned directory

Set base image (host OS)
FROM python:3.8
RUN apt-get update && apt-get install -y \
python-pip
Installing wget command
RUN pip install wget
Copy the dependencies file to the working directory
COPY requirements.txt .
Install dependencies
RUN pip install -r requirements.txt
Trying to install the chrome driver
RUN wget -O /tmp/chromedriver.zip https://chromedriver.storage.googleapis.com/88.0.4324.96/chromedriver_mac64.zip
Why are you using chrome driver for mac distribution in ubuntu container ? I am not sure of what's beneath it, but I guess there might be some issues due to os type.(Not sure)
You can try adding the ubuntu distribution as shown below, it should work.
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - \
sudo sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
sudo apt-get -y update \
sudo apt-get -y install google-chrome-stable
RUN sudo apt-get -y install chromium-chromedriver

yum in dockerfile - There are no enabled repos

I am having issues with installing python3 with yum in dockerfile. I did look on internet, I did try few things, not working. Its just small thing but not able to figure it out. When I try to build below docker file I do get error . I get error at line -
RUN yum install -y oracle-epel-release-el7
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
You can enable repos with yum-config-manager --enable <repo>
The docker file is below.
FROM openjdk:13-jdk-slim
ARG MAVEN_VERSION=3.6.3
ARG USER_HOME_DIR="/root"
ARG SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
# Install prerequisites
RUN apt-get update && apt-get install -y curl
RUN apt-get update && apt-get install -y yum
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
# Install Python 3.6
RUN yum install -y oracle-epel-release-el7
RUN yum install -y python36
# Install AWS CLI
RUN pip3 install awscli
CMD ["/bin/bash"]
Why mix apt and yum? You're already using apt-get, just use it to install your python too:
apt-get install python3.6

Jenkins slave with nodejs to run npm publish

I have a dockerfile where I install nodejs. I create a container from that dockerfile to use as a slave in jenkins. The problem is that when I try to publish (npm publish --registry ...) it says that I need to login first. But I cannot use npm adduser in a jenkins file cause you have to enter user and password manually when it is required. I have tried to add the file .nmrw with a valid token, but it haven't worked. Any idea?
Best regards.
FROM jenkins/ssh-slave
# Install selected extensions and other stuff
RUN apt-get update && apt-get -y --no-install-recommends install && apt-get clean
RUN apt-get install -y curl
# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs && apt-get install -y nginx
The key is in the file .npmrc. You have to have the same server you publish to.
FROM jenkins/ssh-slave
# Install selected extensions and other stuff
RUN apt-get update && apt-get -y --no-install-recommends install && apt-get clean
RUN apt-get install -y curl
ARG NODEJS_VERSION=setup_11.x
# Install nodejs
RUN curl -sL https://deb.nodesource.com/${NODEJS_VERSION} | bash - && apt-get install -y nodejs && apt-get install -y nginx
RUN chown -R jenkins:jenkins /home/jenkins && chmod -R 777 /home/jenkins
COPY .npmrc /home/jenkins/.npmrc
RUN npm -v

Docker image for python3.5 and ubuntu 16.04

I am trying to create a docker image for python 3.5 and Ubuntu 16.04.
I have created the docker file but at the time of requirement installation using pip the package "psycopg2" is giving the error.
psycopg2 needs Postgres installed in.
Dockerfile
FROM ubuntu:16.04
# bring system up-to-date
RUN apt-get update -qq && \
apt-get upgrade -qqy
RUN apt-get update && apt-get install software-properties-common python-software-properties
RUN add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update
RUN apt-get install -y libpq-dev build-essential python3.6 python3.6-dev python3-pip python3.6-venv
RUN apt-get install -y git
# update pip
RUN python3.6 -m pip install pip --upgrade
RUN python3.6 -m pip install wheel
RUN apt-get install -y wget
RUN apt-get install bzip2
RUN rm -rf /usr/share/fonts/truetype/*
RUN apt-get update && apt-get install -y --force-yes gettext libgettextpo-dev fontconfig
# install phantom js
RUN mkdir -p /usr/share && \
cd /usr/share \
&& wget -O phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && tar xvfj phantomjs.tar.bz2 && mv phantomjs-2.1.1-linux-x86_64 phantomjs && rm -rf phantomjs.tar.bz2
RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \
&& apt-get update \
&& apt-get install -y ttf-mscorefonts-installer
COPY ./helvetica /usr/share/fonts/truetype/msttcorefonts
RUN fc-cache -f -v
RUN fc-list | grep -i 'helvetica'
# Requirements have to be pulled and installed here, otherwise caching won't work
COPY ./requirements /requirements
RUN pip3 install -r /requirements/local.txt
COPY ./compose/production/django/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh
RUN chmod +x /entrypoint.sh
COPY ./compose/local/django/start.sh /start.sh
RUN sed -i 's/\r//' /start.sh
RUN chmod +x /start.sh
COPY ./compose/local/django/celery/worker/start.sh /start-celeryworker.sh
RUN sed -i 's/\r//' /start-celeryworker.sh
RUN chmod +x /start-celeryworker.sh
COPY ./compose/local/django/celery/beat/start.sh /start-celerybeat.sh
RUN sed -i 's/\r//' /start-celerybeat.sh
RUN chmod +x /start-celerybeat.sh
WORKDIR /app
ENTRYPOINT ["/entrypoint.sh"]
Is there an available docker image for ubuntu 16.04 and python3.5?

Hyperledger Fabric 1.0 on CentOS Error endorsing chaincode?

I am running CentOS Linux release 7.2.1511 (Core).
Running the "first network" sample of the brand new Hyperledger Fabric 1.0 out yesterday I am getting the error:
Error: Error endorsing chaincode: rpc error: code = Unknown desc = Error starting container: API error (500): {"message":"oci runtime error: container_linux.go:262: starting container process caused \"process_linux.go:339: container init caused \\"read init-p: connection reset by peer\\"\"\n"}
How do I debug further?
My complete installation procedure of prereqs was as follows:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 policycoreutils-python git dos2unux unzip gcc-c++ make
sudo yum-config-manager --enable rhel-7-server-extras-rpms
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm
yum -y install docker-ce
sudo yum -y install docker-ce
sudo systemctl start docker
sudo docker run hello-world
sudo usermod -aG docker root
sudo usermod -aG docker vagrant
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y ./epel-release-latest-7.noarch.rpm
sudo yum install -y python-pip
sudo pip install docker-compose
sudo yum upgrade python*
cd
mkdir docker-compose-hello-world
cd docker-compose-hello-world
echo 'my-test:' > ./docker-compose.yml
echo ' image: hello-world' >> ./docker-compose.yml
docker-compose up
sudo docker-compose up
cd
mkdir golang
cd golang
echo downloading go1.8.3.linux-amd64.tar.gz
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
sudo cp ./go1.8.3.linux-amd64.tar.gz /usr/local
cd /usr/local
sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
sudo vi /etc/profile
cd
sudo curl -sL https://rpm.nodesource.com/setup_6.x | sudo bash -
sudo yum install -y nodejs
sudo npm install npm#latest -g
cd
git clone https://github.com/hyperledger/fabric-samples.git
sudo docker run hello-world
sudo systemctl start docker
sudo docker run hello-world
cd fabric-samples
# Stackoverflow validation asked me to replace short URL
# goo.gl/iX9dek with long one below:
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap-1.0.0.sh | sudo bash
cd first-network
yes | sudo ./byfn.sh -m generate
yes | sudo ./byfn.sh -m up
My NodeJs (node) version is v6.11.1
My npm version is 5.2.0
My Golang version is go1.8.3 linux/amd64
Thanks in advance for any enlightenment!
Resolved!
Inspired by reference https://github.com/moby/moby/issues/34046, I upgraded the Linux kernel using the instructions at:
https://www.tecmint.com/install-upgrade-kernel-version-in-centos-7/
Works perfectly after a reboot and a selection of the new kernel in the boot menu.
Downside: the Vagrant shared folders between the Windows 7 host OS and the CentOS virtual machine no longer work, but that should be fixed by the next Oracle Virtualbox client tools update.

Resources