P
P
Pan Propan2021-08-16 12:50:34
Docker
Pan Propan, 2021-08-16 12:50:34

Why is there no access to a file inside a Docker container?

All good. I'm trying to package in a Django container.

Dockerfile
FROM python:3.9
ENV PYTHONUNBUFFERED 1
WORKDIR /backend
ADD . /backend
COPY start.sh /backend/start.sh
RUN chmod +x ./start.sh
RUN pip install -r /backend/requirements.txt
# RUN ls -a
CMD  ["/backend/start.sh"]


docker-compose.yml
version: "3.9"

volumes:
  db-data:
   
services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    ports:
      - 5432:5432  
    environment:
      - POSTGRES_DB=visionmark
      - POSTGRES_USER=nariman
      - [email protected]
    volumes:
      - db-data:/var/lib/postgresql/data  

  backend:
    build: ./backend
    volumes:
      - .:/backend
    expose:
      - "8000"
    depends_on:
      - db


Project structure
611a349588d5d168146498.png

when running docker-compose I get an error


ERROR: for backend Cannot start service backend: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/backend/start.sh": stat /backend/start .sh: no such file or directory: unknown
ERROR: Encountered errors while bringing up the project.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2021-08-16
@q2digger

I have a question too. you copy the project to /backend in the Dockerfile, ok, I see.
why are you doing this in docker-compise -
volumes:
- .:/backend
i.e. you mount the contents of the working directory in /backend again

A
Alexey Ukolov, 2021-08-16
@alexey-m-ukolov

RUN chmod +x /backend/start.sh

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question