Please, can someone help me? I am a beginner, i don’t know where i got it wrong. i’m trying to build my docker image but when i run: docker build .
, i got the following errors:
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/community: temporary error (try again later)
WARNING: Ignoring APKINDEX.40a3604f.tar.gz: No such file or directory
2 errors; 35 distinct packages available
The command ‘/bin/sh -c apk update’ returned a non-zero code: 2
See below my Dockerfile
file
FROM python:3.7-alpine
MAINTAINER Tboost Technology
#set environment variable
ENV PYTHONUNBUFFERED 1
#install dependencies
COPY ./requirements.txt /requirements.txt
RUN apk update
RUN rm -rf /var/cache/apk/* && \
rm -rf /tmp/*
RUN apk update \
&& apk add --update --no-cache postgresql-client
RUN apk add --update --no-cache --virtual .tmp-build-deps \
gcc libc-dev python3-dev linux-headers postgresql-dev
RUN pip3 install -r /requirements.txt
RUN apk del .tmp-build-deps
#mkdir to store your apps source code
RUN mkdir /app
WORKDIR /app
COPY ./app /app
#create user to run apps in the docker
RUN adduser -D user
#switch to the user
USER user
My docker-compose.yml
file
version: “3”
services:
app:
build:
context: .
ports:
- "8000:8000"
extra_hosts:
- "host.docker.internal:172.17.0.1"
volumes:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=app
- DB_USER=postgres
- DB_PASS=supersecretpassword
depends_on:
- db
db:
image: postgres:11-alpine
restart: always
environment:
- POSTGRES_DB=app
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=supersecretpassword
and my requirements.txt
file
Django>=3.0.7,<3.0.8
djangorestframework>=3.11.0,<3.12.0
psycopg2>=2.7.5,<2.8.0
flake8>=3.6.0,<3.7.0