Installing python using Dockerfile not working [duplicate] - docker

I just made a very simple Docker file in my terminal, basically I did the following:
mkdir pgrouted
cd pgrouted
touch Dockerfile
Now I open the Docker file in the nano editor, and I add the following commands to the Docker file:
FROM ubuntu
MAINTAINER Gautam <gautamx07#yahoo.com>
LABEL Description="pgrouting excercise" Vendor="skanatek" Version="1.0"
ENV BBOX="-122.8,45.4,-122.5,45.6"
# Add pgRouting launchpad repository
RUN sudo apt-add-repository -y ppa:ubuntugis/ppa
RUN sudo apt-add-repository -y ppa:georepublic/pgrouting
RUN sudo apt-get update
# Install pgRouting package (for Ubuntu 14.04)
RUN sudo apt-get install postgresql-9.3-pgrouting
# Install osm2pgrouting package
RUN sudo apt-get install osm2pgrouting
# Install workshop material (optional, but maybe slightly outdated)
RUN sudo apt-get install pgrouting-workshop
# For workshops at conferences and events:
# Download and install from http://trac.osgeo.org/osgeo/wiki/Live_GIS_Workshop_Install
RUN wget --no-check-certificate https://launchpad.net/~georepublic/+archive/pgrouting/+files/pgrouting-workshop_2.0.6-ppa1_all.deb
RUN sudo dpkg -i pgrouting-workshop_2.0.6-ppa1_all.deb
# Review: Not sure weather this should be in the dockerfile
RUN cp -R /usr/share/pgrouting/workshop ~/Desktop/pgrouting-workshop
# Log in as user "user"
RUN psql -U postgres
# Create routing database
RUN CREATE DATABASE routing;
# Add PostGIS functions
RUN CREATE EXTENSION postgis;
# Add pgRouting core functions
CREATE EXTENSION pgrouting;
# Download using Overpass XAPI (larger extracts possible than with default OSM API)
wget --progress=dot:mega -O "sampledata.osm" "http://www.overpass-api.de/api/xapi?*[bbox=${BBOX}][#meta]"
The entire Dockerfile can be see HERE at a glance.
Now when I try to build the Dockerfile, like so:
docker build -t gautam/pgrouted:v1 .
The Dockerfile runs and then I get the below error:
Step 4 : RUN sudo apt-add-repository -y ppa:ubuntugis/ppa
---> Running in c93c3c5fd5e8
sudo: apt-add-repository: command not found
The command '/bin/sh -c sudo apt-add-repository -y ppa:ubuntugis/ppa' returned a non-zero code: 1
Why am I getting this error?

apt-add-repository is just not in the base Ubuntu image. You'll first need to install it. try apt-get install software-properties-common
By the way, you don't need to use sudo in the Dockerfile because the commands run as root by default unless you change to another user with the USER command.

Add these lines before running apt-add-repository command
RUN apt-get update && \
apt-get install -y software-properties-common && \
rm -rf /var/lib/apt/lists/*

thats worked for me:
RUN apt-get update --fix-missing && \
apt-get install -y software-properties-common && \
rm -rf /var/lib/apt/lists/* && \
add-apt-repository ppa:ondrej/php && \
apt install -y nginx php7.4-fpm php7.4-mysql php7.4-curl net-tools telnet php7.4-gd php-mail php7.4 php7.4-common php7.4-sqlite3 php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap unzip && \
rm -rf /var/lib/apt/lists/* && \
apt clean

Related

Docker from running container "bash:docker:command not found"

I am trying to run docker commands from inside my container, but I always get the response "bash: docker: command not found". I've built my image successfully, and run it by trying the following two ways: docker run -it ubuntu bash and docker run -it ubuntu. All is good running the image, however when I try to execute a shell script by doing the following: docker exec ubuntu /path/to/script.sh, I receive the "command not found" error. Here is my Dockerfile:
# syntax=docker/dockerfile:1
FROM ubuntu:focal
WORKDIR /home/mark/Downloads/docker
ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt update && apt -y upgrade
RUN apt -y install software-properties-common wget
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
RUN add-apt-repository -y ppa:cybermax-dexter/mingw-w64-backport
RUN wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | apt-key add -
RUN wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.3.204-focal.list https://packages.lunarg.com/vulkan/1.3.204/lunarg-vulkan-1.3.204-focal.list
RUN apt update && apt -y upgrade
RUN apt -y install build-essential mingw-w64 gcc-11-multilib g++-11-multilib nano sudo vulkan-sdk
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 90 && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 90
RUN update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
RUN update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
RUN update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix
RUN update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
RUN dpkg --add-architecture i386
RUN wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_20.04/Release.key | apt-key add -
RUN sh -c "echo 'deb https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_20.04/ ./' >> /etc/apt/sources.list.d/OBS_WineHQ.list"
RUN sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list
RUN apt update
RUN apt -y build-dep wine
RUN apt -y install libusb-1.0-0-dev libusb-1.0-0-dev:i386 libgcrypt20-dev libx11-dev libx11-dev:i386 libfreetype-dev libfreetype-dev:i386 samba-dev
RUN apt -y install libxpresent-dev libxpresent-dev:i386 libxi-dev:i386 libxcursor-dev:i386 libxxf86vm-dev:i386 libxinerama-dev:i386 libxcomposite-dev:i386
RUN apt -y install libosmesa6-dev:i386 ocl-icd-opencl-dev:i386 libpcap0.8-dev:i386 libdbus-1-dev:i386 libgnutls28-dev:i386 libsane-dev:i386 libgphoto2-dev:i386
RUN apt -y install libpulse-dev:i386 libgstreamer1.0-dev:i386 libudev-dev:i386 libsdl2-dev:i386 libcups2-dev:i386 libv4l-dev:i386 libfontconfig1-dev:i386
RUN apt -y install libgstreamer-plugins-base1.0-dev:i386 libkrb5-dev:i386 libopenal-dev:i386 libvulkan-dev:i386 libldap2-dev:i386 libcapi20-dev:i386
The docker docs say what I am doing should work. What gives?

Can't access port 8080, 50000 and 8888 while installing jenkins and jupyter

I am new to dokers. I need jenkins and jupyter notebook in the same container. I have written the following Dockerfile but I can't access localhost:8888 or 8080 or 50000 when I run this image. However, these ports work very well when I run the official jenkins image. So, I don't know where I am making the mistake in my Dockerfile.
# using ubuntu as base image
FROM ubuntu:20.04
# installing python version 3.8
RUN apt-get update -y \
&& apt-get install -y apt-utils \
&& apt-get install python3.8 -y
# installing jupyter notebook
RUN apt-get install jupyter -y
EXPOSE 8888
# installing jenkins
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install dialog apt-utils -y
RUN apt-get update && apt-get install -y gnupg2
RUN apt-get install -y wget
RUN wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | apt-key add -
RUN sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
RUN apt-get update
RUN apt-get install jenkins -y
EXPOSE 50000 8080
# removing unnecessary files
RUN rm -rf /var/lib/apt/lists/*
COPY sample.py .
LABEL maintainer=Ammar
CMD ["bash"]

How to run glut app inside docker without FBConfig error?

So, I need to develop and run a specific gui app on Ubuntu. Application is based on OpenGL and freeglut. I'd like to develop from macbook, so I tried to use the vs code remote container feature. It worked well, until I needed to run this app. I installed a lot of various gl packages inside container, ran it with xquarts and etc.
And now I met the problem with glut: freeglut (my_app): ERROR: Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow. As I found there, it's a known bug with glut and remote connection. And it's known from 2009! So does anyone know, how to get rid of it? Or I will never run my app inside docker?
My current Dockerfile:
FROM nvidia/cudagl:9.0-devel-ubuntu16.04
# This Dockerfile's base image has a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=user
ENV DEBIAN_FRONTEND noninteractive
# Adding new architecture in package base
RUN dpkg --add-architecture i386
# Installg tools
RUN apt-get update \
&& apt-get -y install sudo software-properties-common zsh wget
# Installing latest git
RUN add-apt-repository ppa:git-core/ppa \
&& apt-get update \
&& apt-get -y install git
# Install C++ tools
RUN apt-get -y install build-essential gcc-multilib g++-multilib cmake cppcheck valgrind
# Install some dependencies
RUN apt-get -y install libc6-dev-i386 libgl1-mesa-dev libglu1-mesa-dev freeglut3 freeglut3-dev libjpeg-turbo8-dev libpng12-dev mesa-utils
# Install dependencies with another architecture
RUN apt-get -y install libgl1-mesa-dev:i386 libglu1-mesa-dev:i386 freeglut3:i386 freeglut3-dev:i386 libpng12-0:i386
# Install nvidia driver
RUN apt-get install -y binutils xserver-xorg-video-all
# Adding new user
RUN groupadd --gid 2000 $USERNAME \
&& useradd --uid 2000 --gid $USERNAME --shell /bin/zsh --create-home $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
USER $USERNAME
ENV DEBIAN_FRONTEND interactive
I don't know how, but now it's working! I've tried to use so many things, so I don't know what exactly helped me. So I'll try to tell everything:
Docker base image become Ubuntu 14.04. I've already tried it before, but it didn't work then.
I've downgraded XQuartz to version 2.7.8
I've pasted this in terminal: defaults write org.macosforge.xquartz.X11 enable_iglx -bool true
Just in case, here is my new Dockerfile:
FROM ubuntu:14.04
# This Dockerfile's base image has a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=user
ENV DEBIAN_FRONTEND noninteractive
# Adding new architecture in package base
RUN dpkg --add-architecture i386
# Install tools
RUN apt-get update \
&& apt-get -y install sudo software-properties-common zsh wget
# Install last git
RUN add-apt-repository ppa:git-core/ppa \
&& apt-get update \
&& apt-get -y install git
# Install C++ tools
RUN apt-get -y install build-essential gcc-multilib g++-multilib cmake cppcheck valgrind
# Install some dependencies
RUN apt-get -y install libc6-dev-i386 libgl1-mesa-dev libglu1-mesa-dev freeglut3 freeglut3-dev libjpeg-turbo8-dev libpng12-dev mesa-utils
# Install dependencies with another architecture
RUN apt-get -y install libgl1-mesa-dev:i386 libglu1-mesa-dev:i386 freeglut3:i386 freeglut3-dev:i386 libpng12-0:i386
# Install nvidia driver
RUN apt-get install -y binutils xserver-xorg-video-all
# Adding new user
RUN groupadd --gid 2000 $USERNAME \
&& useradd --uid 2000 --gid $USERNAME --shell /bin/zsh --create-home $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
USER $USERNAME
ENV DEBIAN_FRONTEND interactive

install python3.6 on amazonlinux docker image

I have been experimenting to create a docker image with python3.6 based on amazonlinux.
So far, I have not been very successful. I use
docker run -it amazonlinux
to start an interactive docker terminal. Inside the terminal, I run "yum install python36" and see the following error message. Note that I copied this step was from an old amazonlinux based Dockerfile. This Dockerfile used to work. So I suspend the error I see below is due to amazon updated their docker linux image
bash-4.2# yum install python36
Loaded plugins: ovl, priorities
amzn2-core | 2.4 kB 00:00:00
No package python36 available.
Error: Nothing to do
I have tried to add a python3.6 repo by following this post
https://janikarhunen.fi/how-to-install-python-3-6-1-on-centos-7 however, it still gives the same error when I run
yum install python36u
Is there any way to add python3.6 to amazonlinux base layer? Thanks in advance.
There is now a far easier answer to this question thanks to aws 'extras'. Now this will work:
amazon-linux-extras install python3
You can check this Dockerfile based on amazon Linux and having python version is PYTHON_VERSION=3.6.4.
Or you can work with your existing one like
ARG PYTHON_VERSION=3.6.4
ARG BOTO3_VERSION=1.6.3
ARG BOTOCORE_VERSION=1.9.3
ARG APPUSER=app
RUN yum -y update &&\
yum install -y shadow-utils findutils gcc sqlite-devel zlib-devel \
bzip2-devel openssl-devel readline-devel libffi-devel && \
groupadd ${APPUSER} && useradd ${APPUSER} -g ${APPUSER} && \
cd /usr/local/src && \
curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
tar -xzf Python-${PYTHON_VERSION}.tgz && \
cd Python-${PYTHON_VERSION} && \
./configure --enable-optimizations && make && make altinstall && \
rm -rf /usr/local/src/Python-${PYTHON_VERSION}* && \
yum remove -y shadow-utils audit-libs libcap-ng && yum -y autoremove && \
yum clean all
But better to clone the repo and make your own image form that.
I too had similiar issue for docker.
yum install docker
Loaded plugins: ovl, priorities
amzn2-core | 3.7 kB 00:00:00
No package docker available.
Error: Nothing to do
instead yum I used amazon-linux-extras, it worked
amazon-linux-extras install docker

apt-add-repository: command not found error in Dockerfile

I just made a very simple Docker file in my terminal, basically I did the following:
mkdir pgrouted
cd pgrouted
touch Dockerfile
Now I open the Docker file in the nano editor, and I add the following commands to the Docker file:
FROM ubuntu
MAINTAINER Gautam <gautamx07#yahoo.com>
LABEL Description="pgrouting excercise" Vendor="skanatek" Version="1.0"
ENV BBOX="-122.8,45.4,-122.5,45.6"
# Add pgRouting launchpad repository
RUN sudo apt-add-repository -y ppa:ubuntugis/ppa
RUN sudo apt-add-repository -y ppa:georepublic/pgrouting
RUN sudo apt-get update
# Install pgRouting package (for Ubuntu 14.04)
RUN sudo apt-get install postgresql-9.3-pgrouting
# Install osm2pgrouting package
RUN sudo apt-get install osm2pgrouting
# Install workshop material (optional, but maybe slightly outdated)
RUN sudo apt-get install pgrouting-workshop
# For workshops at conferences and events:
# Download and install from http://trac.osgeo.org/osgeo/wiki/Live_GIS_Workshop_Install
RUN wget --no-check-certificate https://launchpad.net/~georepublic/+archive/pgrouting/+files/pgrouting-workshop_2.0.6-ppa1_all.deb
RUN sudo dpkg -i pgrouting-workshop_2.0.6-ppa1_all.deb
# Review: Not sure weather this should be in the dockerfile
RUN cp -R /usr/share/pgrouting/workshop ~/Desktop/pgrouting-workshop
# Log in as user "user"
RUN psql -U postgres
# Create routing database
RUN CREATE DATABASE routing;
# Add PostGIS functions
RUN CREATE EXTENSION postgis;
# Add pgRouting core functions
CREATE EXTENSION pgrouting;
# Download using Overpass XAPI (larger extracts possible than with default OSM API)
wget --progress=dot:mega -O "sampledata.osm" "http://www.overpass-api.de/api/xapi?*[bbox=${BBOX}][#meta]"
The entire Dockerfile can be see HERE at a glance.
Now when I try to build the Dockerfile, like so:
docker build -t gautam/pgrouted:v1 .
The Dockerfile runs and then I get the below error:
Step 4 : RUN sudo apt-add-repository -y ppa:ubuntugis/ppa
---> Running in c93c3c5fd5e8
sudo: apt-add-repository: command not found
The command '/bin/sh -c sudo apt-add-repository -y ppa:ubuntugis/ppa' returned a non-zero code: 1
Why am I getting this error?
apt-add-repository is just not in the base Ubuntu image. You'll first need to install it. try apt-get install software-properties-common
By the way, you don't need to use sudo in the Dockerfile because the commands run as root by default unless you change to another user with the USER command.
Add these lines before running apt-add-repository command
RUN apt-get update && \
apt-get install -y software-properties-common && \
rm -rf /var/lib/apt/lists/*
thats worked for me:
RUN apt-get update --fix-missing && \
apt-get install -y software-properties-common && \
rm -rf /var/lib/apt/lists/* && \
add-apt-repository ppa:ondrej/php && \
apt install -y nginx php7.4-fpm php7.4-mysql php7.4-curl net-tools telnet php7.4-gd php-mail php7.4 php7.4-common php7.4-sqlite3 php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap unzip && \
rm -rf /var/lib/apt/lists/* && \
apt clean

Resources