Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 136

Cannot install packages with apt in docker image

$
0
0

I'm trying to create my own postgres image that is supposed to connect to a postgreSQL database hosted on AWS RDS, however, I'm having trouble connecting to that database as well as trouble installing some required packages. The base image is postgres:11.16, with debian as the underlying os as per the cat /etc/os-release which gives the output:

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"NAME="Debian GNU/Linux"VERSION_ID="9"VERSION="9 (stretch)"VERSION_CODENAME=stretchID=debianHOME_URL="https://www.debian.org/"SUPPORT_URL="https://www.debian.org/support"BUG_REPORT_URL="https://bugs.debian.org/"

My dockerfile is defined as:

FROM postgres:11.16ENV DB_HOST=host_name.eu-west-1.rds.amazonaws.comENV PORT=5432ENV DB_NAME=db_nameENV DB_USER=userENV DB_PASSWORD=passEXPOSE 5432 80# RUN apt-get cleanRUN apt-get update && RUN apt-get install -y iputils-pingRUN mkdir -p appCOPY *.sql ./app/COPY entrypoint.sh ./app/RUN chmod +x /app/entrypoint.shENTRYPOINT ["/app/entrypoint.sh"]

with the entrypoint.sh script being:

#!/bin/bashecho "$DB_HOST $PORT $DB_NAME $DB_USER $DB_PASSWORD"# Wait for the PostgreSQL server to be fully runninguntil psql "host=$DB_HOST port=$PORT dbname=$DB_NAME user=$DB_USER password=$DB_PASSWORD" -c "SELECT 1" >/dev/null 2>&1; do    echo "Waiting for PostgreSQL server to start..."    sleep 1done# Execute the SQL scriptpsql "host=$DB_HOST port=$PORT dbname=$DB_NAME user=$DB_USER password=$DB_PASSWORD" -f /app/evaluation.sql

At first I just wanted to connect to the database, but it just kept printing the echo message in the entrypoint.sh script. So I wanted to check if the remote server is reachable with ping, however, it was not installed by default on debian and I tried to install it, but then I ran into more problems. I then tried to install the ping binaries from the definition of the dockerfile but still the same error persisted:

 => ERROR [2/6] RUN apt-get update && RUN apt-get install -y iputils-ping                                                                                                                                                               4.0s------> [2/6] RUN apt-get update && RUN apt-get install -y iputils-ping:pgdg/11/binary-amd64/Packages  404  Not Found [IP: 217.196.149.55 80]#5 3.974 E: Some index files failed to download. They have been ignored, or old ones used instead.------executor failed running [/bin/sh -c apt-get update && RUN apt-get install -y iputils-ping]: exit code: 100

Even though the ports 80 and 5432 are exposed and mapped, as per docker container ps:

0.0.0.0:80->80/tcp, 0.0.0.0:5432->5432/tcp

I still think this might be a networking issue. Any help towards resolving this issue is welcome.


Viewing all articles
Browse latest Browse all 136

Trending Articles