skip to Main Content

I am getting this error when trying to run migrations in my container. I cannot seem to figure out why.

Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: "alembic": executable file not found in $PATH": unknown

Dockerfile:

FROM python:3.8.2
WORKDIR /workspace/
COPY . .
RUN pip install pipenv
RUN pipenv install --deploy --ignore-pipfile
#EXPOSE 8000
#CMD ["pipenv", "run", "python", "/workspace/bin/web.py"]

Docker-Compose:

version: '3'
services:
  db:
    image: postgres:12
    ports:
      - "5432:5432"
    env_file:
      - .env.database.local
  pgadmin:
    container_name: pgadmin
    image: dpage/pgadmin4
    environment:
      - [email protected]
      - PGADMIN_DEFAULT_PASSWORD=admin
    ports:
      - "5050:80"
    depends_on:
      - db
  redis:
    image: "redis:alpine"
  web:
    build: .
    environment:
      - PYTHONPATH=/workspace
    env_file:
      - .env.local
    ports:
      - "8000:8000"
    volumes:
      - .:/workspace
    depends_on:
      - db
      - redis
    command: "alembic upgrade head && pipenv run python /workspace/bin/web.py"

The command I run when I encounter this problem:

docker-compose run web alembic revision - autogenerate -m "First migration"

Project Directory.

I defined in my Dockerfile that all my program will be running in the workspace directory. So it should point to it.

2

Answers


  1. Chosen as BEST ANSWER

    Yes the issue was that I did not add it to my $PATH.

    This is what I added inside my docker-compose:

          - PATH=/directory/bin:$PATH
    

  2. docker-compose run web pipenv run alembic revision - autogenerate -m "First migration"

    or
    change in Dockerfile

    RUN pipenv install --deploy --ignore-pipfile --system

    and run

    docker-compose run web alembic revision - autogenerate -m "First migration"

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search