I could not install the postgresql 9.5 This is the point when I'm in the docker file
Dockerfile row
RUN apt-get update && apt-get install -qq -y build-essential libpq-dev postgresql-client-9.5 --fix-missing --no-install-recommends
and it runs the command bellow.
remote: E: Package 'postgresql-client-9.5' has no installation candidate
remote:
The command '/bin/sh -c apt-get update && apt-get install -qq
-y build-essential libpq-dev postgresql-client-9.5 --fix-missing
--no-install-recommends' returned a non-zero code: 100
Seems that it tries to do apt-get update from debian repository when I'm on ubuntu xenial. May be something went wrong because I installed first wrong docker version for debian , and then I removed the debian docker with
sudo apt-get remove docker docker-engine docker.io
sudo rm -rf /var/lib/docker
After this I have installed the docker for my ubuntu xenial distribution. I don't understand why when I run the docker file it still updates the packages and tries to install packages that are for debian, when I don't have anything debian related?
The installed docker version is
Docker version 17.05.0-ce, build 89658be
From https://apt.dockerproject.org/repo/pool/main/d/docker-engine/docker-engine_17.05.0~ce-0~ubuntu-xenial_amd64.deb
Here is the code when it runs apt-get update:
remote: ---> Running in b8d8101adf4a
remote: ---> f9286d1e85d1
remote: Removing intermediate container b8d8101adf4a
remote: Step 3/11 : RUN apt-get update && apt-get install -qq -y build-essential libpq-dev postgresql-client-9.5 mysql-client-5.7 --fix-missing --no-install-recommends
remote: ---> Running in 9bda34235687
remote: Ign:1 http://deb.debian.org/debian stretch InRelease
remote: Get:2 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
remote: Get:3 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
remote: Get:4 http://deb.debian.org/debian stretch Release [118 kB]
remote: Get:5 http://deb.debian.org/debian stretch-updates/main amd64 Packages [12.1 kB]
remote: Get:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [440 kB]
remote: Get:7 http://deb.debian.org/debian stretch Release.gpg [2434 B]
remote: Get:8 http://deb.debian.org/debian stretch/main amd64 Packages [9530 kB]
remote: Fetched 10.3 MB in 13s (789 kB/s)
remote: Reading package lists...
Dockerfile:
FROM python:2.7
MAINTAINER Makkasi <makkasi#abv.bg>
RUN apt-get update && apt-get install -qq -y build-essential libpq-dev postgresql-client-9.5 --fix-missing --no-install-recommends
ENV INSTALL_PATH /project1
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
VOLUME ["static"]
CMD gunicorn -b 0.0.0.0:8000 "project1.app:create_app()"
docker-compose.yml:
postgres:
image: postgres:9.5
environment:
POSTGRES_USER: makkasi
POSTGRES_PASSWORD: somepassword
ports:
- '5432:5432'
volumes:
- ~/.docker-volumes/project1/postgresql/data:/var/lib/postgresql/data
redis:
image: redis:2.8.22
ports:
- '6379:6379'
volumes:
- ~/.docker-volumes/project1/redis/data:/var/lib/redis/data
project1:
build: .
command: gunicorn -b 0.0.0.0:8000 --reload --access-logfile - "project1.app:create_app()"
environment:
PYTHONUNBUFFERED: true
links:
- postgres
- redis
volumes:
- .:/project1
ports:
- '8000:8000'
I think is a postgresql version question.
If you're using stretch or buster (buster actually updates from stretch servers), version found in repo is postgresql-client-9.6, not 9.5.
Try with this and we see.
Seems that it tries to do apt-get update from debian repository when I'm on ubuntu xenial.
Commands to build an image are run within a container based on the previous state of the image. They do not depend on the host you are running on. The result is the same image could be built on different docker host with nearly identical results (external dependencies and timestamps being the normal exceptions). If you follow the path of the Dockerfile you've provided from the FROM lines, you get:
FROM python:2.7: docker hub and Dockerfile
FROM buildpack-deps:stretch: docker hub and Dockerfile
FROM buildpack-deps:stretch-scm: docker hub and Dockerfile
FROM buildpack-deps:stretch-curl: docker hub and Dockerfile
FROM debian:stretch: docker hub and Dockerfile
You can also run a container based on your base image and use the standard package manager tools to query for what versions of packages are included (this is particularly useful when you don't have the Dockerfile for your image):
$ docker run -it --rm python:2.7 /bin/bash
root#ea64878fc27f:/# cat /etc/debian_version
8.7
root#ea64878fc27f:/# apt-get update
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://deb.debian.org jessie Release.gpg [2434 B]
Get:4 http://deb.debian.org jessie Release [148 kB]
Get:5 http://security.debian.org jessie/updates/main amd64 Packages [623 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]
Fetched 10.1 MB in 9s (1058 kB/s)
Reading package lists... Done
root#ea64878fc27f:/# apt-cache search postgresql-client
postgresql-client-9.4 - front-end programs for PostgreSQL 9.4
postgresql-client - front-end programs for PostgreSQL (supported version)
postgresql-client-common - manager for multiple PostgreSQL client versions
root#ea64878fc27f:/# apt-cache madison postgresql-client
postgresql-client | 9.4+165+deb8u3 | http://deb.debian.org/debian/ jessie/main amd64 Packages
postgresql-client | 9.4+165+deb8u3 | http://security.debian.org/ jessie/updates/main amd64 Packages
Related
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
I am trying to set up a GitLab CI/CD pipeline with this following .gitlab-ci.yml file:
stages:
- test
image: "ros:foxy-ros-base-focal"
before_script:
- apt-get -y update && apt-get install -y \
git wget qt5-default \
python3-osrf-pycommon \
python3-catkin-tools \
python3-rosdep \
python3-vcstool \
python3-pip \
python3-colcon-common-extensions \
apt-utils
- rm -rf /var/lib/apt/lists/*
- /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; colcon build"
- echo "source /root/dev_ws/install/setup.bash" >> /opt/ros/${ROS_DISTRO}/setup.bash
test_a:
stage: test
script:
- pip3 install pytest
- python -m pytest test_utils.py -vv -s
I am starting from the ROS2 Foxy Base Focal Docker image. However, despite running apt-get update, I still can't find many of the packages, including git as well as several other ROS2 packages. Full log here:
Running with gitlab-runner 13.8.0 (775dd39d)
on docker-auto-scale fa6cab46
Preparing the "docker+machine" executor
00:27
Using Docker executor with image ros:foxy-ros-base-focal ...
Pulling docker image ros:foxy-ros-base-focal ...
Using docker image sha256:59cf2af10ce4181bf4effbc683375f5e201bfe072c808c75fb3ee903b98265b9 for ros:foxy-ros-base-focal with digest ros#sha256:4f924ff4fdee6b7c999ad6bc013741bdf8430466c7a27842ac6255255ce9ae66 ...
Preparing environment
00:02
Running on runner-fa6cab46-project-23977848-concurrent-0 via runner-fa6cab46-srm-1611897044-53c1946d...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/imda_dsl/vama-2/scene-understanding/scene-understanding-manager/.git/
Created fresh repository.
Checking out fc385931 as dev...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:05
$ apt-get -y update && apt-get install -y \ git wget qt5-default \ python3-osrf-pycommon \ python3-catkin-tools \ python3-rosdep \ python3-vcstool \ python3-pip \ python3-colcon-common-extensions \ apt-utils
Get:1 http://packages.ros.org/ros2/ubuntu focal InRelease [4670 B]
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Get:4 http://packages.ros.org/ros2/ubuntu focal/main amd64 Packages [451 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [161 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [598 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [659 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [13.3 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1003 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [21.1 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [194 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [920 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [4301 B]
Fetched 17.4 MB in 2s (7001 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package git
E: Unable to locate package python3-osrf-pycommon
E: Unable to locate package python3-catkin-tools
E: Unable to locate package python3-rosdep
E: Unable to locate package python3-vcstool
E: Unable to locate package python3-pip
E: Unable to locate package python3-colcon-common-extensions
E: Unable to locate package apt-utils
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
Installing packages or even running update commands in your .gitlab-ci.yml is generally against best practices for a CI/CD container because each and every job that runs will have to do the same thing, costing a lot of time as you run more pipelines. If you can't find an existing Docker image that has the packages you need (so as an example, python3 and git), you can create your own images. If you need to extend the image from your job, ros:foxy-ros-base-focal, create a Dockerfile file with the following contents:
FROM ros:foxy-ros-base-focal
MAINTAINER your name "your email"
RUN apt-get update -yqq
RUN apt-get install -yqq git
You can install/configure whatever else you need to do in there too, then when you're done build the image:
docker build /path/to/dir-with-dockerfile -t tagname:version
Once the build is done you can verify the tag is correct with docker images, then you can push it to a registry (docker hub, gitlab's registry if enabled, private registry, etc) with:
docker login my.hub.example.com
docker push my.hub.example.com/tagname:version
Then in your .gitlab-ci.yml file, you can use the tagname:version image in your jobs:
stages:
- test
image: "tagname:version"
...
If you have to auth to use your registry, you'll have to review the docs here https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#define-an-image-from-a-private-container-registry, and the general docs for using docker images in your pipelines is here: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html
I am trying to create a Docker image of Cassandra. Cassandra requires Java. I have added line to install java. In my Docker file
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install default-jre
COPY apache-cassandra-3.11.6-bin.tar.gz .
RUN tar -xzf apache-cassandra-3.11.6-bin.tar.gz
RUN chmod -R 777 apache-cassandra-3.11.6
RUN ls
RUN echo $PATH
RUN echo $PWD
RUN apt update
#RUN apt-get install openjdk-7-jdk
#RUN java -version
WORKDIR apache-cassandra-3.11.6
RUN ls
ENV CASSANDRA_HOME=/apache-cassandra-3.11.6
ENV PATH=$PATH:$CASSANDRA_HOME/bin
RUN echo $PATH
RUN ls
WORKDIR apache-cassandra-3.11.6/bin
RUN ls
CMD ["cassandra","-f"]
I am getting error in apt-get update and apt. How can I fix this?
C:\Users\manuc\Documents\manu\cassandra_image_test>docker build -f CassandraImageDockerFile.txt -t manucassandra .
Sending build context to Docker daemon 184.8MB
Step 1/19 : FROM ubuntu:20.04
---> 74435f89ab78
Step 2/19 : RUN apt-get update
---> Running in b395852c8e6b
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Reading package lists...
E: Release file for http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease is not valid yet (invalid for another 1d 13h 27min 45s). Updates for this repository will not be applied.
E: Release file for http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease is not valid yet (invalid for another 1d 12h 39min 24s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease is not valid yet (invalid for another 1d 12h 39min 54s). Updates for this repository will not be applied.
The command '/bin/sh -c apt-get update' returned a non-zero code: 100
This seems to be an issue with your timezone. Please restart your Docker host.
Docker Desktop:
You can manually restart it using UI.
Docker machine:
$ docker-machine restart <DOCKER-MACHINE-NAME>
Podman:
$ podman restart <PODMAN-MACHINE-NAME>
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
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.