i just follow the demo of docker-compose official documentation
virtual machine: VMware Workstation 15 Player
OS: Centos7
docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
Dockerfile:
ROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP app.py
ENV FLASK_RUN_HOST 0.0.0.0
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
CMD ["flask", "run"]
run commend:
docker-compose up
log and error message
Building web
Step 1/9 : FROM python:3.7-alpine
---> 7fbc871584eb
Step 2/9 : WORKDIR /code
---> Using cache
---> c20780a4b2d4
Step 3/9 : ENV FLASK_APP app.py
---> Using cache
---> 973cc407ca91
Step 4/9 : ENV FLASK_RUN_HOST 0.0.0.0
---> Using cache
---> 23891144700d
Step 5/9 : RUN apk add --no-cache gcc musl-dev linux-headers
---> [Warning] IPv4 forwarding is disabled. Networking will not work.
---> Running in 7b29f4df9539
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz: temporary error (try again later)
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz: temporary error (try again later)
ERROR: unsatisfiable constraints:
gcc (missing):
required by: world[gcc]
linux-headers (missing):
required by: world[linux-headers]
musl-dev (missing):
required by: world[musl-dev]
ERROR: Service 'web' failed to build: The command '/bin/sh -c apk add --no-cache gcc musl-dev linux-headers' returned a non-zero code: 3
who can help me?
2
Answers
The root cause of the error that you get is that GCC is not installed (failed to install) on the docker image. Make sure that you have internet connection to install these libs.
from the warning that you have
it seems that Docker containers do not have an internet connection, you must enable the
IPv4 forwarding
using the following commandsmore info can be found here
I solved this problem on fedora by partialy using blog from: https://fedoramagazine.org/docker-and-fedora-32/
Enable old CGroups:
Whitelist docker in firewall:
Install dependencies for docket-composer: