docker-compose returning non-zero code: 100 - docker

I am trying to use docker but am getting this error when I am trying to run docker-compose build I am getting this error. Is this a DNS issue? I tried setting
Output of sudo docker-compose build:
Building php
Step 1 : FROM pvlltvk/ubuntu-trusty-php-fpm-5.6
---> d48912228ec2
Step 2 : RUN apt-get install -y php5-curl php5-sybase freetds-dev libxml2-dev
---> Running in 0c614dc10ae3
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
ca-certificates freetds-common libct4 libcurl3 libidn11 librtmp0 libsybdb5
openssl
Suggested packages:
pkg-config
The following NEW packages will be installed:
ca-certificates freetds-common freetds-dev libct4 libcurl3 libidn11 librtmp0
libsybdb5 libxml2-dev openssl php5-curl php5-sybase
0 upgraded, 12 newly installed, 0 to remove and 3 not upgraded.
Need to get 2752 kB of archives.
After this operation, 8659 kB of additional disk space will be used.
Err http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/ trusty/main openssl amd64 1.0.2h-1+deb.sury.org~trusty+1
404 Not Found
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main libidn11 amd64 1.28-1ubuntu2 [93.0 kB]
Err http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/ trusty/main php5-curl amd64 5.6.23+dfsg-1+deprecated+dontuse+deb.sury.org~trusty+1
404 Not Found
Err http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/ trusty/main php5-sybase amd64 5.6.23+dfsg-1+deprecated+dontuse+deb.sury.org~trusty+1
404 Not Found
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main librtmp0 amd64 2.4+20121230.gitdf6c518-1 [57.5 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty/main freetds-common all 0.91-5 [24.3 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty/main libct4 amd64 0.91-5 [166 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ trusty/main libcurl3 amd64 7.35.0-1ubuntu2 [172 kB]
Get:6 http://archive.ubuntu.com/ubuntu/ trusty/main libsybdb5 amd64 0.91-5 [194 kB]
Get:7 http://archive.ubuntu.com/ubuntu/ trusty/main ca-certificates all 20130906ubuntu2 [175 kB]
Get:8 http://archive.ubuntu.com/ubuntu/ trusty/main freetds-dev amd64 0.91-5 [514 kB]
Get:9 http://archive.ubuntu.com/ubuntu/ trusty/main libxml2-dev amd64 2.9.1+dfsg1-3ubuntu4 [628 kB]
Fetched 2023 kB in 34s (58.1 kB/s)
E: Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/pool/main/o/openssl/openssl_1.0.2h-1+deb.sury.org~trusty+1_amd64.deb 404 Not Found
E: Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/pool/main/p/php5/php5-curl_5.6.23+dfsg-1+deprecated+dontuse+deb.sury.org~trusty+1_amd64.deb 404 Not Found
E: Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/pool/main/p/php5/php5-sybase_5.6.23+dfsg-1+deprecated+dontuse+deb.sury.org~trusty+1_amd64.deb 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
ERROR: Service 'php' failed to build: The command '/bin/sh -c apt-get install -y php5-curl php5-sybase freetds-dev libxml2-dev' returned a non-zero code: 100
This is the docker file:
FROM pvlltvk/ubuntu-trusty-php-fpm-5.6
RUN apt-get install -y \
php5-curl \
php5-sybase \
freetds-dev \
libxml2-dev
ADD freetds.conf /etc/freetds/freetds.conf
RUN echo 'alias sf="php /app/app/console"' >> ~/.bashrc
WORKDIR /app
If I run sudo cat /etc/default/docker:
DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4"

Docker images do not include a package repository cache, they take up disk space and would quickly become out of date. It looks like you're building from an image that included a stale repository cache. Change your run command to pull the current repository status, run non-interactively, and cleanup when finished:
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
php5-curl \
php5-sybase \
freetds-dev \
libxml2-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
See the best practices for more details.

Related

Pyodbc not installing in Docker image

I'm trying to use a Docker image with SQLAlchemy, which have dependencies with pyodbc. I'm trying to get the package installed from the Dockerfile, but I'm not finding the solution anywhere.
Right now, the basic structure of the directory could be like this:
root
| notebooks
| |testAlchemy.ipynb
| Dockerfile
| docker-compose.yml
| requirements.txt
Here are the contents of requirements.txt:
ipython-sql
pyodbc
psycopg2
sqlalchemy
Here my dockerfile:
FROM jupyter/datascience-notebook:latest
USER root
RUN apt-get update && \
apt-get install -y libpq-dev build-essential && \
apt-get clean && rm -rf var/lib/apt/lists/*
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
VOLUME /notebooks
WORKDIR /notebooks
And here the docker-compose:
version: "3"
services:
jupyter:
build:
context: ./jupyter
ports:
- "8888:8888"
links:
- postgres
environment:
- JUPYTER_TOKEN=1234
volumes:
- "./notebooks:/notebooks"
- "./data:/data"
postgres:
image: postgres
restart: always
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: passw
ports:
- 5432:5432
Then I do docker compose up and connect to jupyter server
In the notebook I have a really simple code:
from sqlalchemy.engine import URL
from sqlalchemy import create_engine
connection_string = f"DATABASE=operational;UID=user;PWD=passw;HOST=postgres"
connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": connection_string})
engine = create_engine(connection_url)
But every time I try to run this code I get this error:
moduleNotFoundError img
And obviously, if I run !pip list in the notebook, pyodbc doesn't show anywhere. But I can run !pip install pyodbc with no problem
I'm sure I'm doing something wrong, but I don't know what.
Maybe try this recipe from their site, linked below, this is the CONDA+requirements file version:
FROM jupyter/datascience-notebook:latest
USER root
RUN apt-get update && \
apt-get install -y libpq-dev build-essential && \
apt-get clean && rm -rf var/lib/apt/lists/*
COPY --chown=${NB_UID}:${NB_GID} connect.py "/home/${NB_USER}"
COPY --chown=${NB_UID}:${NB_GID} requirements.txt /tmp/
#RUN pip install --quiet --no-cache-dir --requirement /tmp/requirements.txt && \
# fix-permissions "${CONDA_DIR}" && \
# fix-permissions "/home/${NB_USER}"
RUN mamba install --yes --file /tmp/requirements.txt && \
mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
VOLUME /notebooks
WORKDIR /notebooks
using-mamba-install-or-pip-install-in-a-child-docker-image
Output
$ docker build --no-cache .
Sending build context to Docker daemon 42.06MB
Step 1/8 : FROM jupyter/datascience-notebook:latest
---> 03fcab0a8478
Step 2/8 : USER root
---> Running in a064e6e68110
Removing intermediate container a064e6e68110
---> f1681b20edb3
Step 3/8 : RUN apt-get update && apt-get install -y libpq-dev build-essential && apt-get clean && rm -rf var/lib/apt/lists/*
---> Running in 4622166e35a4
Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:4 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [767 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages [1,792 kB]
Get:8 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [614 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [4,642 B]
Get:10 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [522 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [266 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [17.5 MB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [573 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [8,056 B]
Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [914 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [952 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [7,275 B]
Get:18 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages [3,175 B]
Fetched 24.7 MB in 5s (5,102 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
build-essential is already the newest version (12.9ubuntu3).
The following additional packages will be installed:
libpq5 libssl-dev
Suggested packages:
postgresql-doc-14 libssl-doc
The following NEW packages will be installed:
libpq-dev libpq5 libssl-dev
0 upgraded, 3 newly installed, 0 to remove and 5 not upgraded.
Need to get 2,659 kB of archives.
After this operation, 13.4 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpq5 amd64 14.5-0ubuntu0.22.04.1 [140 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libssl-dev amd64 3.0.2-0ubuntu1.7 [2,372 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpq-dev amd64 14.5-0ubuntu0.22.04.1 [147 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 2,659 kB in 1s (2,739 kB/s)
Selecting previously unselected package libpq5:amd64.
(Reading database ... 49774 files and directories currently installed.)
Preparing to unpack .../libpq5_14.5-0ubuntu0.22.04.1_amd64.deb ...
Unpacking libpq5:amd64 (14.5-0ubuntu0.22.04.1) ...
Selecting previously unselected package libssl-dev:amd64.
Preparing to unpack .../libssl-dev_3.0.2-0ubuntu1.7_amd64.deb ...
Unpacking libssl-dev:amd64 (3.0.2-0ubuntu1.7) ...
Selecting previously unselected package libpq-dev.
Preparing to unpack .../libpq-dev_14.5-0ubuntu0.22.04.1_amd64.deb ...
Unpacking libpq-dev (14.5-0ubuntu0.22.04.1) ...
Setting up libpq5:amd64 (14.5-0ubuntu0.22.04.1) ...
Setting up libssl-dev:amd64 (3.0.2-0ubuntu1.7) ...
Setting up libpq-dev (14.5-0ubuntu0.22.04.1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Removing intermediate container 4622166e35a4
---> 1c46f27c2516
Step 4/8 : COPY --chown=${NB_UID}:${NB_GID} connect.py "/home/${NB_USER}"
---> acab4c589e51
Step 5/8 : COPY --chown=${NB_UID}:${NB_GID} requirements.txt /tmp/
---> 3b506e4bdd02
Step 6/8 : RUN mamba install --yes --file /tmp/requirements.txt && mamba clean --all -f -y && fix-permissions "${CONDA_DIR}" && fix-permissions "/home/${NB_USER}"
---> Running in ced464550b21
Transaction
Prefix: /opt/conda
Updating specs:
- ipython-sql
- pyodbc
- psycopg2
- sqlalchemy
- ca-certificates
- certifi
- openssl
Package Version Build Channel Size
───────────────────────────────────────────────────────────────────────────
Install:
───────────────────────────────────────────────────────────────────────────
+ ipython-sql 0.3.9 pyhd8ed1ab_1004 conda-forge/noarch 19kB
+ libpq 14.5 he2d8382_1 conda-forge/linux-64 3MB
+ prettytable 3.4.1 pyhd8ed1ab_0 conda-forge/noarch 27kB
+ psycopg2 2.9.3 py310h5764c6d_1 conda-forge/linux-64 185kB
+ pyodbc 4.0.35 py310hd8f1fbe_0 conda-forge/linux-64 79kB
+ sqlparse 0.4.3 pyhd8ed1ab_0 conda-forge/noarch 36kB
Summary:
Install: 6 packages
Total download: 3MB
───────────────────────────────────────────────────────────────────────────
Looking for: ['ipython-sql', 'pyodbc', 'psycopg2', 'sqlalchemy']
Pinned packages:
- python 3.10.*
- python 3.10.6
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Will remove 1 package cache(s).
Removing intermediate container ced464550b21
---> ddfbf0e82d8a
Step 7/8 : VOLUME /notebooks
---> Running in 6991a675e302
Removing intermediate container 6991a675e302
---> 1cadb017d264
Step 8/8 : WORKDIR /notebooks
---> Running in 44b9027d2e6d
Removing intermediate container 44b9027d2e6d
---> c888d15b3e82
Successfully built c888d15b3e82

How to fix 'python: not found' error when using PostCreateCommand in vscode remote docker extension

I'm using the Visual Studio Code Remote - Containers extension with a customized DockerFile. It is based on https://github.com/microsoft/vscode-dev-containers/blob/master/containers/python-3/.devcontainer/Dockerfile but uses a different base image and doesn't try to pip install from requirements.txt.
When I build the container in vscode, with PostCreateCommand set to "python --version", the following errors appears in the dev containers terminal output:
Run: docker exec -w /workspaces/media-classifier dd5e552b4f113ecf74504cc6d3aed3ca1727b4a172645515392c4632b7c45b81 /bin/sh -c python --version
/bin/sh: 1: python: not found
postCreateCommand "python --version" failed.
I've tried using the same setting value for PostCreateCommand (python --version) using both the standard python3 container and the python3 anaconda container and they both successfully output the python version.
I've also tried setting PostCreateCommand to the following values, which all produce the same 'not found' error:
pip --version
conda --version
When the container has started, I'm successfully able to use python, pip and conda so they are definitely installed.
Dockerfile
FROM microsoft/cntk:2.6-cpu-python3.5
# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
#
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& apt-get -y install git procps lsb-release \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
devcontainer.json
{
"name": "CNTK Python3.5",
"context": "..",
"dockerFile": "Dockerfile",
// Uncomment the next line if you want to publish any ports.
// "appPort": [],
// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "python --version",
"extensions": [
"ms-python.python",
"neuron.neuron-ipe"
],
"settings": {
"python.pythonPath": "/opt/conda/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true
}
}
I'm expecting PostCreateCommand to execute successfully and output the python version installed in whichever anaconda environment is active at the time.
you are trying to run python when python3 is installed
try running
python3 --version
Since python3 is not a direct replacement for python v2, Debian based systems have not setup an automatic alias to point python to the python3 binaries. The recommended solution is to point all python v3 commands to python3. The workaround for applications that can't be easily updated is to setup an alias to point python to python3 anyway.
FROM microsoft/cntk:2.6-cpu-python3.5
# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
#
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& apt-get -y install \
git \
lsb-release \
procps \
python-is-python3 \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
For more on this, see https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3
From the comments, here's a similar example with a different base image, also fixed by installing python-is-python3:
$ docker run -it --rm --entrypoint bash mcr.microsoft.com/vscode/devcontainers/dotnet:0.202.1-6.0
Unable to find image 'mcr.microsoft.com/vscode/devcontainers/dotnet:0.202.1-6.0' locally
0.202.1-6.0: Pulling from vscode/devcontainers/dotnet
e5ae68f74026: Pull complete
a74667493539: Pull complete
3a0bffe13264: Pull complete
913bac4f4fc9: Pull complete
d2ea5cb43486: Pull complete
1414be57e953: Pull complete
868d7bfddf03: Pull complete
63ab446ca68f: Pull complete
1259b98fc625: Pull complete
802a0f1d31f7: Pull complete
094ecb532868: Pull complete
f643f7ed0620: Pull complete
Digest: sha256:d3bfb3e7c9ecfcb4472b59272e2f8857807667c0bd83fb1da935d28e9087e733
Status: Downloaded newer image for mcr.microsoft.com/vscode/devcontainers/dotnet:0.202.1-6.0
root ➜ / $ type python
bash: type: python: not found
root ➜ / $ type python3
python3 is /usr/bin/python3
root ➜ / $ apt-get update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB]
Get:5 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [102 kB]
Get:6 http://deb.debian.org/debian bullseye/contrib amd64 Packages [50.5 kB]
Get:7 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
Get:8 https://dl.yarnpkg.com/debian stable/main all Packages [10.5 kB]
Get:9 https://dl.yarnpkg.com/debian stable/main amd64 Packages [10.5 kB]
Get:10 http://deb.debian.org/debian bullseye/non-free amd64 Packages [93.8 kB]
Get:11 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2592 B]
Fetched 8670 kB in 3s (3246 kB/s)
Reading package lists... Done
root ➜ / $ apt-get install -y python-is-python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
python-is-python3
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
Need to get 2800 B of archives.
After this operation, 13.3 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 python-is-python3 all 3.9.2-1 [2800 B]
Fetched 2800 B in 0s (67.0 kB/s)
Selecting previously unselected package python-is-python3.
(Reading database ... 22711 files and directories currently installed.)
Preparing to unpack .../python-is-python3_3.9.2-1_all.deb ...
Unpacking python-is-python3 (3.9.2-1) ...
Setting up python-is-python3 (3.9.2-1) ...
Processing triggers for man-db (2.9.4-2) ...
root ➜ / $ type python
python is /usr/bin/python

CI/CD package is different from local package [jessie/stretch inconsistency]

When I run docker on local machine with following Dockerfile:
FROM python:3
WORKDIR /app
COPY . /app
RUN apt-get update && apt-get install -y libhunspell-1.3-0
RUN pip install -r requirements.txt
EXPOSE 9876
CMD ["python","flask_compose.py"]
It got libhunspell from following repository (jessie):
Get:1 http://security.debian.org jessie/updates InRelease [94.4 kB]
Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:3 http://security.debian.org jessie/updates/main amd64 Packages [623 kB]
Get:4 http://deb.debian.org jessie Release.gpg [2434 B]
Get:5 http://deb.debian.org jessie Release [148 kB]
Get:6 http://deb.debian.org jessie-updates/main amd64 Packages [23.0 kB]
Get:7 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
And everything is fine (image build and run successfully).
Unfortunately, when I run docker on gitlab repository with the same Dockerfile it calls update apt-get from another repository (stretch):
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:3 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:4 http://deb.debian.org/debian stretch Release [118 kB]
Get:5 http://deb.debian.org/debian stretch Release.gpg [2434 B]
Get:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [440 kB]
Get:7 http://deb.debian.org/debian stretch-updates/main amd64 Packages [12.1 kB]
Get:8 http://deb.debian.org/debian stretch/main amd64 Packages [9530 kB]
Due to this inconsistency gitlab CI/CD throws following exception:
E: Unable to locate package libhunspell-1.3-0
E: Couldn't find any package by glob 'libhunspell-1.3-0'
E: Couldn't find any package by regex 'libhunspell-1.3-0'
The command '/bin/sh -c apt-get install -y libhunspell-1.3-0' returned a non-zero code: 100
ERROR: Job failed: exit code 100
Does anyone knows how change my Dockerfile that local and gitlab uses the same package repository?
There current tag for python:3 points to a Debian stretch based image. To update your local environment, run a docker pull python:3 or run your build with the --pull option.
You can also select a more specific tag to force your desired base image used by python. See the docker hub page for python to see all the possible tags, e.g. python:3-jessie.
From gitlab official forum I found a solution which fixed my problem.
1) define a setup.sh file and following command:
echo "deb http://pkg.adfinis-sygroup.ch/debian/ jessie main non-free contrib" > /etc/apt/sources.list
echo "deb http://security.debian.org/ jessie/updates main" >> /etc/apt/sources.list
echo "deb http://pkg.adfinis-sygroup.ch/debian/ jessie-updates main contrib non-free" >> /etc/apt/sources.list
apt-get update
apt-get install --no-install-recommends -y libhunspell-1.3-0
2) In Dockerfile add following commands:
From python:3
ADD setup.sh /opt/
RUN /bin/bash /opt/setup.sh
PS: Although my hack works very fine, I prefer #BMitch solution.
--------------------------------------------------------------------------------------------------------
By extending #Bmitch solution I decrease image size from ~600 to ~150 with following Dockerfile:
FROM python:3-slim-jessie
WORKDIR .
# hunspell deps
RUN apt-get update && apt-get install --no-install-recommends -y libtool libc6-dev gcc g++ build-essential libhunspell-1.3-0
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
CMD ["python","flask_compose.py"]

Install php7.0-pgsql inside docker php:7.0-apache

I try to install php7.0-pgsql inside my php:7.0-apache image.
I know there are a lot of comparable issues on the internet but I really need help for this:
FROM php:7.0-apache
RUN apt-get -y update && \
apt-get -y install software-properties-common locales locales-all && \
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php && \
apt-get -y update && \
apt-get -y install php7.0-pgsql
COPY src/ /var/www/html
The following error appears during my docker build:
# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
gpg: keyring `/tmp/tmppxe6egn8/secring.gpg' created
gpg: keyring `/tmp/tmppxe6egn8/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmppxe6egn8/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
Hit http://security.debian.org jessie/updates InRelease
Ign http://ppa.launchpad.net jessie InRelease
Ign http://ppa.launchpad.net jessie Release.gpg
Get:1 http://security.debian.org jessie/updates/main amd64 Packages [549 kB]
Ign http://ppa.launchpad.net jessie Release
Err http://ppa.launchpad.net jessie/main amd64 Packages
Ign http://deb.debian.org jessie InRelease
Err http://ppa.launchpad.net jessie/main amd64 Packages
Hit http://deb.debian.org jessie-updates InRelease
Hit http://deb.debian.org jessie Release.gpg
Err http://ppa.launchpad.net jessie/main amd64 Packages
Err http://ppa.launchpad.net jessie/main amd64 Packages
Hit http://deb.debian.org jessie Release
Err http://ppa.launchpad.net jessie/main amd64 Packages
404 Not Found
Get:2 http://deb.debian.org jessie-updates/main amd64 Packages [17.8 kB]
Get:3 http://deb.debian.org jessie/main amd64 Packages [9063 kB]
Fetched 9630 kB in 11s (870 kB/s)
W: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/dists/jessie/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c apt-get -y update && apt-get -y install software-properties-common locales locales-all && LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php && apt-get -y update && apt-get -y install php7.0-pgsql' returned a non-zero code: 100
Here an excerpt from a Dockerfile I am using
FROM php:7.1-apache
RUN apt-get update \
&& apt-get install --no-install-recommends -y libpq-dev \
&& docker-php-ext-install pgsql \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
I am compiling the extensions myself since the PHP within the official images is also compiled from source and not taken from the Debian repository.

Docker: Unable to correct problems, you have held broken packages

I have Dockerfile that I have used many times without an issue. Now I need to add some packages to it (ssmtp and sendmail) and when I add them the build fails with:
Sending build context to Docker daemon 645.3 MB
Sending build context to Docker daemon
Step 0 : FROM debian:jessie
---> 736e5442e772
Step 1 : MAINTAINER Larry Martell <larry.martell#foo.com>
---> Using cache
---> bd272aa26940
Step 2 : ENV HOME /opt/django/CAPgraph/
---> Using cache
---> 1c540ed91808
Step 3 : RUN echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list
---> Using cache
---> 8788d48e625d
Step 4 : RUN (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf ssmtp sendmail)
---> Running in 8986bca93fdb
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:2 http://security.debian.org jessie/updates/main amd64 Packages [436 kB]
Get:3 http://http.debian.net jessie-backports InRelease [166 kB]
Get:4 http://httpredir.debian.org jessie-updates InRelease [145 kB]
Get:5 http://http.debian.net jessie-backports/main amd64 Packages [1031 kB]
Get:6 http://httpredir.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Ign http://httpredir.debian.org jessie InRelease
Get:7 http://httpredir.debian.org jessie Release.gpg [2373 B]
Get:8 http://httpredir.debian.org jessie Release [148 kB]
Get:9 http://httpredir.debian.org jessie/main amd64 Packages [9049 kB]
Fetched 11.1 MB in 9s (1211 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
sendmail : Depends: sendmail-bin but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf ssmtp sendmail)' returned a non-zero code: 100
If I add those packages to the list I then complains about others. What does this 'held broken packages' message mean and how do I fix it?
Here is the first part of my Dockerfile:
FROM debian:jessie ENV HOME /opt/django/CAPgraph/
RUN echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list
RUN (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf sendmail ssmtp)
I tried adding sendmail-bin and then it failed with:
The following packages have unmet dependencies:
sendmail-bin : Conflicts: mail-transport-agent
ssmtp : Conflicts: mail-transport-agent
E: Unable to correct problems, you have held broken packages.
I then added mail-transport-agent and it failed with:
Package mail-transport-agent is a virtual package provided by:
opensmtpd 5.7.3p2-1~bpo8+1
ssmtp 2.64-8
sendmail-bin 8.14.4-8+deb8u1
qmail-run 2.0.2+nmu1
postfix 2.11.3-1
nullmailer 1:1.13-1+deb8u1
msmtp-mta 1.4.32-2
masqmail 0.2.30-1
lsb-invalid-mta 4.1+Debian13+nmu1
exim4-daemon-light 4.84.2-2+deb8u3
exim4-daemon-heavy 4.84.2-2+deb8u3
esmtp-run 1.2-12
dma 0.9-1
courier-mta 0.73.1-1.6
citadel-mta 8.24-1+b3
E: Package 'mail-transport-agent' has no installation candidate
Debian is setup to only allow one mail transport agent, and your install command is trying to include two, ssmtp and sendmail/sendmail-bin. Since they conflict with each other, you'll need to remove one of these from your install command.
If the sendmail dependency is so your Python app can send email via the sendmail binary, just install ssmtp and configure it to use an external MTA.
Trying to run sendmail in a Docker container is not recommended

Resources