在docker容器中运行迁移时出错。

问题描述 投票:0回答:1

当我试图在容器中运行迁移时,我得到了这个错误。我似乎不明白为什么。

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"

当我遇到这个问题时,我运行的命令。

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

Project Directory.

我在我的Dockerfile里定义了我所有的程序都会在工作区目录下运行。所以它应该指向它。

python docker-compose dockerfile alembic
1个回答
0
投票

是的,问题是我没有把它添加到我的$PATH中。

这是我在docker-compose里面添加的。

      - PATH=/directory/bin:$PATH
© www.soinside.com 2019 - 2024. All rights reserved.