Compose: The Dockerfile could not find the docker-compose volume file

Created on 24 Mar 2020  Â·  1Comment  Â·  Source: docker/compose

Dockerfile could not find the docker-compose volume file when using the RUN command

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.25.4, build 8d51620a
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.1c  28 May 2019

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

services:
  pyweb:
    build:
      context: E:\dev\compose_demo
    ports:
    - 8000:5000/tcp
    volumes:
    - E:\dev\compose_demo:/code:rw
version: '3.0'

Steps to reproduce the issue

This is a demo where I can reproduce the problem。I have 4 files in the same path:

  1. app.py
# app.py
from flask import Flask


app = Flask(__name__)


@app.route('/')
def index():
    return 'Hello World'


if __name__ == "__main__":
    app.run(host="0.0.0.0", debug=True)
  1. requirements.txt
click==7.1.1
Flask==1.1.1
itsdangerous==1.1.0
Jinja2==2.11.1
MarkupSafe==1.1.1
Werkzeug==1.0.0
  1. docker-compose.yml
version: '3'

services:
  pyweb:
    build: .
    ports:
      - "8000:5000"
    volumes:
      - .:/code
  1. Dockerfile
FROM ubuntu:18.04

RUN apt update
RUN apt -y install python3 python3-pip
RUN pip3 install -r /code/requirements.txt

WORKDIR /code

CMD ["python3", "app.py"]
  1. run docker-compose up

Observed result

RUN pip3 install -r /code/requirements.txt error

Expected result

It should work

Stacktrace / full error message

Could not open requirements file: [Errno 2] No such file or directory: '/code/requirements.txt'
Service 'pyweb' failed to build: The command '/bin/sh -c pip3 install -r /code/requirements.txt' returned a non-zero code: 1

Additional information

OS: Windows and Linux

I found these files exist when I entered the docker container, and pip 3 install -r /code/requirements.txt was able to run successfully in the docker container.

kinbug

Most helpful comment

Any updates here?

Have spent the past 2 days trying to figure out whether I was crazy or whether or not this was an actual issue.

Same exact thing with me on Docker version 19.03.12, build 48a66213fe and docker-compose version 1.26.2, build eefe0d31 on OSX 10.15.6

docker-compose refuses to see the files mounted at the volume -- giving me a container exited with status code 127 -- /bin/bash files not found.

However, if I exec into the container they are clearly there and work as expected.

Is there any temporary workaround here?

>All comments

Any updates here?

Have spent the past 2 days trying to figure out whether I was crazy or whether or not this was an actual issue.

Same exact thing with me on Docker version 19.03.12, build 48a66213fe and docker-compose version 1.26.2, build eefe0d31 on OSX 10.15.6

docker-compose refuses to see the files mounted at the volume -- giving me a container exited with status code 127 -- /bin/bash files not found.

However, if I exec into the container they are clearly there and work as expected.

Is there any temporary workaround here?

Was this page helpful?
0 / 5 - 0 ratings