2

I'm having some error when building with sudo docker-compose up. The image builts well but when running the container it throws the following two errors:

ERROR: for b21bd1503fed_django-docker-boilerplate_web_1 Cannot start service web: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: write sysctl key net.ipv4.ip_unprivileged_port_start: open /proc/sys/net/ipv4/ip_unprivileged_port_start: no such file or directory: unknown

ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: write sysctl key net.ipv4.ip_unprivileged_port_start: open /proc/sys/net/ipv4/ip_unprivileged_port_start: no such file or directory: unknown

I'm running docker on MacOS Catalina and the versions of docker and docker compose are version 20.10.5, build 55c4c88 and version 1.28.5, build c4eb3a1f respectively.

My configuration files are the following: directories

.
|-- Dockerfile
|-- README.md
|-- docker-compose.yml
`-- requirements.txt

Dockerfile

FROM python:3.10.0a6-slim-buster

WORKDIR .

ENV PYTHONUNBUFFERED=1

# Copy file into the working directory
COPY requirements.txt .
RUN pip install -r requirements.txt

# Copy source code into the image
COPY . .

docker-compose.yml

version: "3.9"

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .
    ports: 
      - "8000:8000"
    env_file: 
      - ./.env

Any idea what's going on wrong here?

Rodragon
  • 135
  • 3
  • 12
  • 1
    Volumes are supposed to be mapping in the form 'host_path:container_path', I guess just `.` is interpreted as `.:/` (or `.:.` which is the same result) and therefore the filesystem of the container is not really ok. You need to set where to mount the volume in your container. If you want it to be in the `WORKDIR`, better to set `WORKDIR` to something else than `.` which is `/` by default in most images. – zigarn Mar 23 '21 at 07:41
  • I used a root directory because I was having another problem later when building Django. The command `manage.py` seems it adds a bigger path. Just like mentioned here. https://stackoverflow.com/questions/31565640/no-django-app-created-when-following-the-docker-compose-tutorial – Rodragon Mar 23 '21 at 09:50
  • @zigarn That solved this issue. Thanks – Rodragon Mar 23 '21 at 10:05

1 Answers1

0

I met the same issue as in this question, and I've solved it; now my environment is:

  1. kernel version is 5.4.242-1.el7.elrepo.x86_64
  2. OS version is CentOS Linux release 7.9.2009 (Core)

you may refer to https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/ip-sysctl.txt?h=v4.11#n832

and https://github.com/istio/istio/issues/36560.

when I upgraded my kernel version from 3.x to 5.x, it works as expected. you can upgrade your virtual machine's kernel version to 5.x to fix this issue.

PavanDevarakonda
  • 625
  • 5
  • 27
xiangqian
  • 1
  • 1