J
J
jecer_inside2022-03-18 16:59:50
Python
jecer_inside, 2022-03-18 16:59:50

How to correctly specify the path to the folder, for use in docker?

when running the image, docker throws an error

File "/usr/src/app/./index.py", line 26, in handle_text
    photo = open('test/' + random.choice(os.listdir('test')), 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'test'


the docker file itself
FROM python:3-alpine
WORKDIR /usr/src/app
LABEL version="1.0"
COPY /* ./
RUN pip install -r requirements.txt
CMD [ "python", "./index.py" ]


using test folder in script
if message.text.lower() == 'получить вопрос':
        photo = open('test/' + random.choice(os.listdir('test')), 'rb')


how to fix this error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jecer_inside, 2022-03-18
@jecer_inside

it was necessary to specify in docerfile
COPY ./ ./
instead of
COPY /* ./

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question