docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
34.01k stars 5.23k forks source link

docker-compose run not able to find 'C:\\Users\\compose_spec.json' #9397

Closed SimplifyOrg closed 1 year ago

SimplifyOrg commented 2 years ago

I am trying to run hello world Django app inside docker. For this I am using Docker-compose and Dockerfile (file contents below). However, when I try to create a new Django project using docker-compose run I get this error (full error log below):

Traceback (most recent call last):
  File "jsonschema\validators.py", line 774, in resolve_from_url
  File "jsonschema\_utils.py", line 22, in __getitem__
KeyError: 'file:///C:/Users/compose_spec.json'

Steps to reproduce the issue:

  1. Inside a new directory create docker-compose.yml and Dockerfile.
  2. Create a requirements.txt in the same directory.
  3. Contents of docker-compose.yml

      version: "3"
    
      services:
         web:
             build: .
             command: python manage.py runserver 0.0.0.0:8000
             volumes:
                - .:/app
             ports:
                - "8000:8000"
  4. Contents of Dockerfile:
    FROM python:3.10.4
    ENV PYTHONUNBUFFERED 1
    RUN mkdir /app
    WORKDIR /app
    COPY requirements.txt /app/
    RUN pip install -r requirements.txt
    COPY . /app/
  5. Contents of requirements.txt:
    Django==3.2.12
  6. Command I ran to start a new Django project inside docker: docker-compose run web django-admin startproject airfarms .

Describe the results you received: I docker-compose seems to look for C:\Users\compose_spec.json, which it is not present on my computer.

After running docker-compose run web django-admin startproject airfarms . I get following error log:

Traceback (most recent call last):
  File "jsonschema\validators.py", line 774, in resolve_from_url
  File "jsonschema\_utils.py", line 22, in __getitem__
KeyError: 'file:///C:/Users/compose_spec.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "urllib\request.py", line 1499, in open_local_file
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\compose_spec.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "jsonschema\validators.py", line 777, in resolve_from_url
  File "jsonschema\validators.py", line 863, in resolve_remote
  File "urllib\request.py", line 214, in urlopen
  File "urllib\request.py", line 517, in open
  File "urllib\request.py", line 534, in _open
  File "urllib\request.py", line 494, in _call_chain
  File "urllib\request.py", line 1477, in file_open
  File "urllib\request.py", line 1516, in open_local_file
urllib.error.URLError: <urlopen error [WinError 2] The system cannot find the file specified: 'C:\\Users\\compose_spec.json'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 81, in main
  File "compose\cli\main.py", line 200, in perform_command
  File "compose\cli\command.py", line 60, in project_from_options
  File "compose\cli\command.py", line 148, in get_project
  File "compose\config\config.py", line 423, in load
  File "compose\config\config.py", line 424, in <listcomp>
  File "compose\config\config.py", line 626, in process_config_file
  File "compose\config\validation.py", line 474, in validate_against_config_schema
  File "compose\config\validation.py", line 537, in handle_errors
  File "jsonschema\validators.py", line 328, in iter_errors
  File "jsonschema\_validators.py", line 282, in properties
  File "jsonschema\validators.py", line 344, in descend
  File "jsonschema\validators.py", line 328, in iter_errors
  File "jsonschema\_validators.py", line 23, in patternProperties
  File "jsonschema\validators.py", line 344, in descend
  File "jsonschema\validators.py", line 328, in iter_errors
  File "jsonschema\_validators.py", line 259, in ref
  File "jsonschema\validators.py", line 766, in resolve
  File "jsonschema\validators.py", line 779, in resolve_from_url
jsonschema.exceptions.RefResolutionError: <urlopen error [WinError 2] The system cannot find the file specified: 'C:\\Users\\compose_spec.json'>
[14540] Failed to execute script docker-compose

Describe the results you expected: I expected docker-compose run web django-admin startproject airfarms . to successfully create a Django project inside the docker container.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker compose version:

docker-compose version 1.29.2, build 5becea4c

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.1)
  compose: Docker Compose (Docker Inc., v2.3.3)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.13
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2a1d4dbdb2a1030dc5b01e96fb110a9d9f150ecc
 runc version: v1.0.3-0-gf46b6ba
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.16.3-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 3.745GiB
 Name: docker-desktop
 ID: BXYP:PST5:D2CW:7R5U:V4OV:IL2A:ETDS:AA27:PHQT:L54G:KSAL:IQ5C
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Additional environment details: Windows 11

MistaIA commented 2 years ago

Ran on the same issue

Differences are on our configurations

1- requirements.txt :

Django==4.0.5
djangorestframework==3.13.1
mysqlclient==2.1.0
django-mysql==4.7.0
django-cors-headers==3.13.0
pika==1.2.1

2- Dockerfile :

FROM python:3.9
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app

CMD python manage.py runserver 0.0.0.0:8000

3- docker-compose.yml :

version: '3.9'
services:
  backend:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 8000:8000
    volumes:
      - .:/app

4- command : docker-compose up

Additional environment details: Windows 10

ndeloof commented 1 year ago

The Python version of Compose is reaching EOL in a few months, could you please give a try to the Compose V2 version and let us know if you still have the issue?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ndeloof commented 1 year ago

I'm closing this issue as obsolete: Docker Compose V1 has reached end-of-life and we are not accepting any more changes. Please try and reproduce your issue with Compose V2 and create a new issue or PR with the relevant Compose V2 information.