skip to Main Content

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


  1. 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

    ---> [Warning] IPv4 forwarding is disabled. Networking will not work.
    

    it seems that Docker containers do not have an internet connection, you must enable the IPv4 forwarding using the following commands

    echo 1 > /proc/sys/net/ipv4/ip_forward
    sysctl -w net.ipv4.ip_forward=1
    sysctl -p /etc/sysctl.conf
    

    more info can be found here

    Login or Signup to reply.
  2. I solved this problem on fedora by partialy using blog from: https://fedoramagazine.org/docker-and-fedora-32/

    Enable old CGroups:

    sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"
    

    Whitelist docker in firewall:

    sudo firewall-cmd --permanent --zone=trusted --add-interface=docker0
    sudo firewall-cmd --permanent --zone=FedoraWorkstation --add-masquerade
    

    Install dependencies for docket-composer:

    sudo dnf install python3-attrs python3-bcrypt python3-cached_property python3-docker python3-docker-pycreds python3-dockerpty python3-docopt python3-fluidity-sm python3-invoke python3-jsonschema python3-lexicon python3-paramiko python3-pyasn1 python3-pynacl python3-pyrsistent python3-texttable python3-websocket-client
    
    sudo reboot
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search