Issue building docker image: Unable to locate package / command returns non-zero code 100 - docker

I am new to Docker.
I used the following command to build an image but I get errors:
sudo docker build -t docker-custom-app .
Dockerfile:
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -y &&\
apt-get install -y curl &&\
apt-get install -y python3 &&\
apt-get install -y python3-pip &&\
pip install flask &&\
pip install flask-mysql
COPY . /opt/source-code
ENTRYPOINT FLASK_APP=/opt/source-code/app.py flask run
The error I get:
E: Unable to locate package curl
The command '/bin/sh -c apt-get update && apt-get upgrade -y &&apt-get install -y curl &&apt-get install -y python3 &&apt-get install -y python3-pip &&pip install flask &&pip install flask-mysql' returned a non-zero code: 100
even if I use another RUN command, e.g.
RUN apt-get update && apt-get upgrade -y &&\
apt-get install -y software-properties-common &&\
pip install flask &&\
pip install flask-mysql
I get https://i.stack.imgur.com/0h3Cw.png
E: Unable to locate package software-properties-common
The command '/bin/sh -c apt-get update && apt-get upgrade -y &&apt-get install -y software-properties-common &&pip install flask &&pip install flask-mysql' returned a non-zero code: 100
Or another RUN command example:
RUN apt-get update && apt-get upgrade -y &&\
apt-get install -y python3 &&\
apt-get install -y software-properties-common &&\
pip install flask &&\
pip install flask-mysql
I get an error:
E: Unable to locate package python3
The command '/bin/sh -c apt-get update && apt-get upgrade -y &&apt-get install -y python3 &&apt-get install -y software-properties-common &&pip install flask &&pip install flask-mysql' returned a non-zero code: 100
I always get an error something like Unable to locate package/returned a non-zero code:100
Any help is appreciated. Thanks.

apt-get update caused the issue, it didn't work. I think your docker installation is somehow broken or you installed docker in a wrong way. Maybe you are on mac.

Related

Docker Compose: Apt-utils installation problem

I am trying to build a new image in Docker Compose but the following problem occurs
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apt/apt-utils_2.4.7_amd64.deb 404 Not Found [IP: ]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get install -y apt-utils' returned a non-zero code: 100
ERROR: Service 'nginx-service' failed to build : Build failed
In my Dockerfile I'm running: RUN apt-get install -y apt-utils and with --fix-missing.
None of the related questions or other solutions helped me and I've been stuck for quite a while. What am I missing?
Thanks!
EDIT: The whole Dockerfile
FROM ubuntu:latest
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y nginx
RUN apt-get clean
RUN apt-get install -y curl
RUN apt-get install -y unzip
RUN apt-get install -y wget
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get install -y php php-xml php-curl php-fpm php-mysql
RUN apt-get install -y apt-utils --fix-missing
RUN apt-get install -y php-zip --fix-missing
RUN apt-get install -y php-gd --fix-missing
RUN apt-get install -y mysql-server
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php
RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN apt-get install -y nano
RUN apt-get install -y mc
RUN apt-get install -y systemctl
RUN systemctl start nginx.service
usually , when we are building a new image, we use update then install like this
RUN apt-get update && apt-get install -y apt-utils
This will update apt source list and will make the package available to install.
Addibg this to your Dockerfile should fix the issue.
If you want to install many at once you can add the packages like the following :
RUN apt-get update && apt-get install -y \
bzr \
cvs \
git \
mercurial \
subversion \
Building the image like this:
docker-compose build --no-cache
worked for me

Dockerfile Ubuntu with interactive install

I'm making this post to you, because I'm currently doing a docker file from a UBUNTU 20.04.
In my dockerfile I run installs which for some require multiple choice questions with "interactive" answer.
So I wanted to know how I could automate the thing.
I leave you attached my docker file, I put a hash in front of the packages causing me problem.
RUN apt-get update
RUN rm -f /etc/localtime && ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
RUN apt-get install apache2 -y
RUN apt install gnupg
RUN apt-get install wget
RUN cd /tmp
RUN wget https://dev.mysql.com/get/mysql-apt-config_0.8.20-1_all.deb
#RUN apt install ./mysql-apt-config_0.8.20-1_all.deb -y
RUN apt-get install mysql-server -y
RUN apt-get install mysql-client
RUN apt-get install php -y
RUN apt-get install vim -y
RUN apt-get install nano
RUN apt-get install pv
RUN apt-get install php-mysql -y
RUN apt-get install libapache2-mod-php
RUN apt-get install git-core -y
RUN apt-get install unoconv -y
RUN apt-get install poppler-utils
#RUN apt-get install ttf-mscorefonts-installer -y
#RUN apt-get install wkhtmltopdf -y
#RUN apt-get install backup-manager
RUN apt-get install xvfb
RUN apt-get install php-imap -y
RUN apt-get install php-intl -y
#RUN apt-get install php-mcrypt
RUN apt-get install curl
RUN apt-get install php-curl -y
RUN apt-get install openssl
RUN apt-get install ssl-cert
RUN apt-get install php-mbstring -y
RUN apt-get install php-xml -y
RUN apt-get install php-imagick -y
RUN apt-get install php-zip -y
#RUN apt-get install postfix -y```
Thank you for your help ;D
add the following before calling apt-get
ENV DEBIAN_FRONTEND=noninteractive
or prepend DEBIAN_FRONTEND=noninteractive before apt-get command, such as DEBIAN_FRONTEND=noninteractive apt-get install curl -y

Dockerfile can't open ODBC driver 17 and fails during running the python script

I have create in docker 2 contains 1 to run the MSSQL server and the other a python container with the code to read data from an .xlsx file and inserting it into SQL server.
My Dockerfile has the below code :
FROM python:3.6-alpine
RUN apk update
RUN apk add gcc libc-dev g++ libffi-dev libxml2 unixodbc-dev mariadb-dev postgresql-dev
FROM continuumio/miniconda3
ADD test.py /
RUN apt-get update -y \
&& apt install python3 -y \
&& apt install python3-pip -y \
&& apt install python3-venv -y \
&& python3 -m venv venv
RUN apt-get -y install curl
**#Install FreeTDS and dependencies for PyODBC**
RUN apt-get update && apt-get install -y tdsodbc unixodbc-dev \
&& apt install unixodbc-bin -y \
&& apt-get clean -y
RUN apt-get update
RUN apt-get install -y tdsodbc unixodbc-dev
RUN apt install unixodbc-bin -y
RUN apt-get clean -y
RUN pip install pandas
RUN pip install pyodbc
RUN pip install DateTime
RUN pip install multiprocess
RUN pip install threaded
CMD [ "python", "./test.py" ]
It compiles successfully but fails every time i run the container with the below error :
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
I have been trying this for days but found no resolution.
Believe I need to install ODBC driver 17, if so how do I add it to my Dockerfile?

Install PIP3 and PYTHON3.7 on Docker Ubuntu 18.04

I have to install Python3.7 and pip3 for Python3.7 on my Docker Ubuntu18.04. I can install the 3.7, but I cannot get rid of pip3 for Python3.6:
FROM ubuntu:18.04
# ...
RUN apt-get update && apt-get install -y \
software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y \
python3.7 \
python3-pip
RUN python3.7 -m pip install pip
RUN apt-get update && apt-get install -y \
python3-distutils \
python3-setuptools
and I have
root#ef0c924ba7fa:/tornado_api# python3.7 --version
Python 3.7.3
root#ef0c924ba7fa:/tornado_api# pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
while it should be pip3 under /usr/lib/python3.7/
Currently, I get
root#ef0c924ba7fa:/tornado_api# which pip3
/usr/bin/pip3
root#ef0c924ba7fa:/tornado_api# readlink $(which pip3)
root#ef0c924ba7fa:/tornado_api#
It looks like this has gone stale, nevertheless, I was wondering whether by simply doing a python3.7 -m pip install --upgrade pip
FROM ubuntu:18.04
# ...
RUN apt-get update && apt-get install -y \
software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y \
python3.7 \
python3-pip
RUN python3.7 -m pip install pip
RUN apt-get update && apt-get install -y \
python3-distutils \
python3-setuptools
RUN python3.7 -m pip install pip --upgrade pip
Try 'sudo apt purge pip3' or 'sudo apt-get purge pip3'
If that does not work then try uninstalling pip3 with pip3. (I'm not that sure how)
My next thing to try is to update pip3 with 'pip3 install pip3' (I think)
If those don't work then I don't know.
If you don't need any complex installations, you can simply use a python:3.7 docker image as base. It is anyways a linux based image with all the python requirements installed.
Explore different python images and usage: https://hub.docker.com/_/python
Eg.:
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./your-daemon-or-script.py" ]
Or if your requirement needs the same ubuntu image used, you can refer to this answer: Install pip in docker
Just reinstall
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.7 get-pip.py --force-reinstall
This work fine for me...
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y software-properties-common gcc && \
add-apt-repository -y ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y python3.8 python3-distutils python3-pip python3-apt

Dockerfile failed because of E: Version x for y was not found

I wrote the following Dockerfile:
FROM ubuntu:14.04
MAINTAINER X
# Setup OS
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get -y install python-software-properties
RUN apt-get -y install software-properties-common
RUN add-apt-repository ppa:nebc/bio-linux
RUN apt-get update
RUN apt-get install -y wget
RUN apt-get install -y python-setuptools python-docutils python-pip
#RUN pip install snakemake
RUN apt-get install -y emboss=6.6.0+dfsg-2biolinux1
RUN apt-get install -y hmmer=3.1b1-0biolinux1
RUN apt-get install -y lastz=1.02.00-3biolinux1.1
RUN apt-get install -y ncbi-blast+=2.2.28-3ubuntu1
Unfortunately, I have got the following errors, but the packages are listed here
E: Version '3.1b1-0biolinux1' for 'hmmer' was not found
E: Version '2.2.28-3ubuntu1' for 'ncbi-blast+' was not found
How can install the above packages with a specific version?

Resources