docker 容器中缺少Dagster可执行文件

wwodge7n  于 2024-01-06  发布在  Docker
关注(0)|答案(2)|浏览(204)

我一直在尝试创建一个在Dagster云中运行的容器,该容器采用ECS混合部署模型。我能够将容器推送到Dagster,但我不断收到此错误:

  1. dagster_cloud.workspace.ecs.client.EcsServiceError: ECS service failed because task arn:aws:ecs:ap-northeast-1:*****:task/Dagster-Cloud-my-cluster-Cluster/1d151e6d40b44588a4ed4446a949d44a failed: CannotStartContainerError: ResourceInitializationError: failed to create new container runtime task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "dagster": executable file not found in $PATH: unknown
  2. Task logs:
  3. runc create failed: unable to start container process: exec: "dagster": executable file not found in $PATH
  4. For more information about the failure, check the ECS console for logs for task arn:aws:ecs:ap-northeast-1:*****:task/Dagster-Cloud-my-cluster-Cluster/1d151e6d40b44588a4ed4446a949d44a in cluster Dagster-Cloud-my-cluster-Cluster.
  5. File "/dagster-cloud/dagster_cloud/workspace/user_code_launcher/user_code_launcher.py", line 1304, in _reconcile
  6. self._wait_for_new_server_ready(
  7. File "/dagster-cloud/dagster_cloud/workspace/ecs/launcher.py", line 458, in _wait_for_new_server_ready
  8. task_arn = self.client.wait_for_new_service(
  9. File "/dagster-cloud/dagster_cloud/workspace/ecs/client.py", line 491, in wait_for_new_service
  10. return self.check_service_has_running_task(
  11. File "/dagster-cloud/dagster_cloud/workspace/ecs/client.py", line 607, in check_service_has_running_task
  12. self._raise_failed_task(task, container_name, logger)
  13. File "/dagster-cloud/dagster_cloud/workspace/ecs/client.py", line 526, in _raise_failed_task
  14. raise EcsServiceError(

字符串
我不知道为什么会发生这种情况,因为我确定我正在安装dagster和dagster-cloud,根据文档。我的Docker容器看起来像这样:

  1. ###############################################################################
  2. # Base container
  3. ###############################################################################
  4. FROM python:3.11 AS base
  5. # Define the environment variables necessary to work with poetry
  6. ENV POETRY_VERSION=1.5.1 \
  7. POETRY_HOME="/opt/poetry" \
  8. POETRY_VIRTUALENVS_IN_PROJECT=true \
  9. POETRY_NO_INTERACTION=1
  10. # Add the poetry bin to our path
  11. ENV PATH="$POETRY_HOME/bin:$PATH"
  12. ###############################################################################
  13. # Poetry installer container
  14. ###############################################################################
  15. FROM base AS installer
  16. # Install poetry
  17. RUN curl -sSL https://install.python-poetry.org | python3 -
  18. ###############################################################################
  19. # Container that actually builds the application
  20. ###############################################################################
  21. FROM base AS builder
  22. # Copy the poetry files from the poetry installer to this container
  23. COPY --from=installer $POETRY_HOME $POETRY_HOME
  24. # Describe the environment variables necessary to install our dependencies
  25. ENV PYTHONFAULTHANDLER=1 \
  26. PYTHONUNBUFFERED=1 \
  27. PYTHONHASHSEED=random \
  28. PIP_NO_CACHE_DIR=off \
  29. PIP_DISABLE_PIP_VERSION_CHECK=on \
  30. PIP_DEFAULT_TIMEOUT=100
  31. # Set the working directory to one we can install to easily
  32. WORKDIR /app
  33. # Copy the poetry.lock and pyproject.toml files first to ensure that dependencies
  34. # are only installed when they're updated
  35. COPY poetry.lock pyproject.toml /app/
  36. # Copy in our SSH key so we can retrieve the shared GitHub repo
  37. RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
  38. # Install our project dependencies
  39. RUN --mount=type=ssh poetry install --only dagster --no-ansi --no-root
  40. # Build the project
  41. COPY . /app/
  42. RUN poetry build
  43. ###############################################################################
  44. # Create a runtime environment that's much smaller
  45. ###############################################################################
  46. FROM python:3.11-alpine AS runtime
  47. # Set the working directory to where Dagster will look for the application
  48. WORKDIR /opt/dagster/app
  49. # Copy the project wheel file
  50. COPY --from=builder /app/dist/*.whl /
  51. # Install the wheel file using pip and then install dagster and dagster-cloud
  52. RUN pip install --no-cache-dir /*.whl \
  53. && rm -rf /*.whl


对于这个包,我的pyproject.toml文件列出了我的依赖项如下:

  1. [tool.poetry.group.dagster.dependencies]
  2. dagster = "^1.5.9"
  3. dagster-aws = "^0.21.9"
  4. pendulum = "^2.1.2"
  5. pandas = "^2.1.3"
  6. openpyxl = "^3.1.2"
  7. dagster-cloud = "^1.5.12"


所以,这两个都应该安装,但显然他们没有。我在这里做错了什么?

quhf5bfb

quhf5bfb1#

您可能忘记激活虚拟环境了?如果它位于/.venv,我建议添加

  1. # Activate virtual env (i.e. setting VIRTUAL_ENV and extending PATH)
  2. ENV VIRTUAL_ENV=/.venv \
  3. PATH="/.venv/bin:$PATH"

字符串
在Dockerfile的结尾。

tp5buhyn

tp5buhyn2#

这个容器有两个问题:
1.我正在推动整个虚拟环境,但这并不包括与一些软件包一起安装的可执行文件,这导致了错误。
1.安装wheel不会安装包的要求。
为了解决这些问题,我使用Poetry构建了一个requirements.txt文件,然后使用pip安装其中的需求。由于这些需求包括dagsterdagster-cloud,因此该软件包最终包含了两个必要的可执行文件。

  1. ###############################################################################
  2. # Base container
  3. ###############################################################################
  4. FROM python:3.11 AS base
  5. # Define the environment variables necessary to work with poetry
  6. ENV POETRY_VERSION=1.5.1 \
  7. POETRY_HOME="/opt/poetry" \
  8. POETRY_VIRTUALENVS_IN_PROJECT=true \
  9. POETRY_NO_INTERACTION=1
  10. # Add the poetry bin to our path
  11. ENV PATH="$POETRY_HOME/bin:$PATH"
  12. ###############################################################################
  13. # Poetry installer container
  14. ###############################################################################
  15. FROM base AS installer
  16. # Install poetry
  17. RUN curl -sSL https://install.python-poetry.org | python3 -
  18. ###############################################################################
  19. # Container that actually builds the application
  20. ###############################################################################
  21. FROM base AS builder
  22. # Copy the poetry files from the poetry installer to this container
  23. COPY --from=installer $POETRY_HOME $POETRY_HOME
  24. # Describe the environment variables necessary to install our dependencies
  25. ENV PYTHONFAULTHANDLER=1 \
  26. PYTHONUNBUFFERED=1 \
  27. PYTHONHASHSEED=random \
  28. PIP_NO_CACHE_DIR=off \
  29. PIP_DISABLE_PIP_VERSION_CHECK=on \
  30. PIP_DEFAULT_TIMEOUT=100
  31. # Set the working directory to one we can install to easily
  32. WORKDIR /app
  33. # Copy the poetry.lock and pyproject.toml files first to ensure that dependencies
  34. # are only installed when they're updated
  35. COPY poetry.lock pyproject.toml /app/
  36. # Create a requirements.txt file we can use
  37. RUN poetry export --with dagster --without-hashes --with-credentials -f requirements.txt --output requirements.txt
  38. ###############################################################################
  39. # Create a runtime environment that's much smaller
  40. ###############################################################################
  41. FROM python:3.11 AS runtime
  42. # Copy in our SSH key so we can retrieve the shared GitHub repo
  43. RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
  44. # # Set the working directory to where Dagster will look for the application
  45. WORKDIR /opt/dagster/app
  46. # # Copy the project files
  47. COPY --from=builder ./app/requirements.txt /opt/dagster/app
  48. COPY . /opt/dagster/app
  49. # Install all the requirements and then install the package itself
  50. RUN --mount=type=ssh pip install -r requirements.txt
  51. RUN pip install -e .

字符串

展开查看全部

相关问题