Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't copy specific files to /app in a Dockerfile

I want to copy all of my python ,.py, files in my folder to my /app folder and according to this SO question I should be able to just do

FROM python:3.10.2-slim-bullseye

#Copy stuff into /app
COPY ./*.py /app

# set workdir as "/app"
WORKDIR /app 

#run
python train.py

but it throws the error mkdir /var/lib/docker/overlay2/jonf4h3njxr8zj28bxlyw7ztd/merged/app: not a directory when it reaches the third line WORKDIR /app.

I have tried several "versions" i.e COPY *.py /app, COPY /*.py /app but neither works

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If I just copy everything i.e COPY . /app it works fine, but insted of floating my .dockerignore with stuff I don’t need, I just want to copy my python-files only.

>Solution :

You need to create the app directory first

FROM python:3.10.2-slim-bullseye

# Create directory
RUN mkdir /app

#Copy stuff into /app
COPY ./*.py /app

# set workdir as "/app"
WORKDIR /app 

#run
python train.py

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading