No such file or directory when trying to COPY file in docker container
2
votes
0
answers
9039
views
This question was asked before. However I can't seem to fix this. I am trying to COPY a file to my docker container, but it keeps telling me that the directory doesn't exist, even though it does. I can copy other folders, but not this specific one.
My directory structure simplified:
- app
--.envs
-- .local
-- .django
--requirements
-- production
-- local
--compose
-- morefiles
When I run `COPY ./requirements /requirements
then this works without a problem. But when I run
COPY ./.envs/.local/.django /
` it tells me:
> Service 'django' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder264874195/.envs/.local/.django: no such file or directory
I assume is that .envs
is being somewhere excluded but I don't know where. I checked the docker-ignore file like recommended in [
COPY failed: stat /var/lib/docker/tmp/docker-builder918577595/...](https://github.com/moby/moby/issues/34986) , but also if I delete all content in the dockerignore
I get the same error.
I tried renaming the folder without the .
but still the same result. Not really sure what else I can try. I tried changing paths moving the command within the Dockerfile
but nothing. I get the same behaviour with ADD.
My docker-compose
file:
version: '3'
volumes:
local_postgres_data: {}
local_postgres_data_backups: {}
services:
django:
build:
context: .
dockerfile: ./compose/local/django/Dockerfile
image: mywebsite_local_django
depends_on:
- postgres
volumes:
- .:/app
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
- "8000:8000"
command: /start
postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: mywebsite_production_postgres
volumes:
- local_postgres_data:/var/lib/postgresql/data
- local_postgres_data_backups:/backups
env_file:
- ./.envs/.local/.postgres
And here is my dockerfile:
FROM python:3.8-alpine
COPY ./.envs/.production/.django /
COPY ./compose/local/django/pre_deploy_hook /
RUN chmod +x /pre_deploy_hook && /pre_deploy_hook
ENV PYTHONUNBUFFERED 1
ARG ADMIN_PORT=some_default_value
ENV ADMIN_PORT=${ADMIN_PORT}
ARG DJANGO_AWS_ACCESS_KEY_ID=defaultvalueoverwritteninnextline
ENV DJANGO_AWS_ACCESS_KEY_ID=${DJANGO_AWS_ACCESS_KEY_ID}
ARG DJANGO_AWS_SECRET_ACCESS_KEY=defaultvalueoverwritteninnextline
ENV DJANGO_AWS_SECRET_ACCESS_KEY=${DJANGO_AWS_SECRET_ACCESS_KEY}
ARG DJANGO_AWS_STORAGE_BUCKET_NAME=defaultvalueoverwritteninnextline
ENV DJANGO_AWS_STORAGE_BUCKET_NAME=${DJANGO_AWS_STORAGE_BUCKET_NAME}
ARG DJANGO_SECRET_KEY=defaultvalueoverwritteninnextline
ENV DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY}
RUN apk update \
# psycopg2 dependencies
&& apk add --virtual build-deps gcc python3-dev musl-dev \
&& apk add postgresql-dev \
# Pillow dependencies
&& apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
# CFFI dependencies
&& apk add libffi-dev py-cffi \
# Translations dependencies
&& apk add gettext \
# https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
&& apk add postgresql-client \
## Needed for sphinx https://github.com/pydanny/cookiecutter-django/issues/1747
&& apk add make
##Needed when installing pandas as requirement
#RUN apk add --update curl gcc g++
#RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install -r /requirements/local.txt
COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r//' /entrypoint
RUN chmod +x /entrypoint
COPY ./compose/local/django/start /start
RUN sed -i 's/\r//' /start
RUN chmod +x /start
WORKDIR /app
ENTRYPOINT ["/entrypoint"]
Could it be that I specify the .env file in the compose file? Because by placing the file into another folder it works.... But that's not what I want...
Asked by Micromegas
(121 rep)
Mar 4, 2020, 03:53 PM
Last activity: Sep 5, 2020, 05:42 PM
Last activity: Sep 5, 2020, 05:42 PM