0

I'm run docker in windows10 ,my dockerfile like this

FROM python:2.7-slim

WORKDIR E:/docker

ADD . E:/docker

RUN pip install -r requirements.txt

EXPOSE 80

ENV NAME World

CMD ["python", "app.py"]

when i run docker build -t friendlyhello . i get a wrong like this:

E:\docker-demo>docker build -t friendlyhello .

Sending build context to Docker daemon  4.608kB

Step 1/7 : FROM python:2.7-slim

 ---> d0d1b97dd328

Step 2/7 : WORKDIR E:/docker

 ---> Using cache

 ---> 305b573b82a5

Step 3/7 : ADD . E:/docker

 ---> 6d25bd33ba84

Step 4/7 : RUN pip install -r E:/docker-demo/requirements.txt

 ---> Running in e68dd3cd1c71

Could not open requirements file: [Errno 2] No such file or directory: 'E:/docker-demo/requirements.txt'

The command '/bin/sh -c pip install -r E:/docker-demo/requirements.txt' returned a non-zero code: 1

it make the RUN as /bin/sh -c. but it shoud be cmd /S /C in windows ,and it can be worked when I run the pip install -r requirements.txt at commonds lines direct.I have no idea how to resove it.thanks for answer

4 Answers4

2

requirements.txt should be present at the same location where your docker file is

gargkshitiz
  • 2,130
  • 17
  • 19
  • yes,there're in the same location. it can be worked when I run the code pip install -r requirements.txt at the commond, – tangtangtang Jun 07 '18 at 14:29
1

Replace E:/docker with /tmp/ (any suitable path in form of linux directory structure) in dockerfile and execute docker build -t friendlyhello .

my dockerfile:

FROM python:2.7-slim

WORKDIR /tmp/

ADD . /tmp/

RUN pip install -r requirements.txt

EXPOSE 80

ENV NAME World

CMD ["python", "app.py"]
dkb
  • 4,389
  • 4
  • 36
  • 54
0

One idea would be to specify the full path to the requirements.txt and make sure that it exists

0

You have to find correct context for docker to start from. Try navigating to parent folder and use -f argument of "docker build" to specify path to Dockerfile:

cd ../ParentFolder
docker build -f ../ParentFolder/ChildFolder/Dockerfile -t imagename .

Otherwise, try editing your Dockerfile

Sergey Nikitin
  • 845
  • 2
  • 13
  • 25