使用Docker-Compose本地运行胶水容器

发布于 2025-01-23 15:42:31 字数 792 浏览 5 评论 0原文

我想使用此命令$ docker run -It -v〜/.aws:/home/glue_user/.aws -e aws_profile = $ profile_name -e disable_ssl = true -rm -p 4040:4040 -p 18080:18080:18080 -name glue_pyspark amazon/aws -glue -libs:glue_libs_3.0.0.0.image_image_01 pyspark pyspark ///docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-libraries.html“ rel =“ nofollow noreferrer”> pyspark-glue-container ,而不是作为<而不是<代码> Docker Run 我想以docker-compose运行。因此,在撰写文件下创建的是:

container_name: "glue_container"
image: amazon/aws-glue-libs:glue_libs_2.0.0_image_01
environment:
  DISABLE_SSL: "true"
ports:
  - 4040:40404
  - 18080:18080
command: pyspark
volumes:
  - ${PWD}/local_path_to_workspace:/home/glue_user/workspace/

但是我无法获得胶水pyspark弹壳并运行吗?但是容器正在出现错误。

I would like to run REPL shell (Pyspark) from the glue container using this command $ docker run -it -v ~/.aws:/home/glue_user/.aws -e AWS_PROFILE=$PROFILE_NAME -e DISABLE_SSL=true --rm -p 4040:4040 -p 18080:18080 --name glue_pyspark amazon/aws-glue-libs:glue_libs_3.0.0_image_01 pyspark mentioned in pyspark-glue-container but instead of running as docker run I would like to run as docker-compose. Hence created below compose file:

container_name: "glue_container"
image: amazon/aws-glue-libs:glue_libs_2.0.0_image_01
environment:
  DISABLE_SSL: "true"
ports:
  - 4040:40404
  - 18080:18080
command: pyspark
volumes:
  - ${PWD}/local_path_to_workspace:/home/glue_user/workspace/

but I'm not able to get the glue pyspark shell up and running? but the container is exiting with an error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倥絔 2025-01-30 15:42:31

我猜您有一个“卷必须是映射”错误

尝试此格式

services:
  pyspark_repl:
    image: amazon/aws-glue-libs:glue_libs_2.0.0_image_01
    environment:
      DISABLE_SSL: "true"
    ports:
      - 4040:40404
      - 18080:18080
    command: pyspark
    volumes: 
      - ${PWD}:/home/glue_user/workspace/

,然后像这样运行

docker-compose run --rm pyspark_repl

I'm guessing you got a "volume must be a mapping" error

Try this format

services:
  pyspark_repl:
    image: amazon/aws-glue-libs:glue_libs_2.0.0_image_01
    environment:
      DISABLE_SSL: "true"
    ports:
      - 4040:40404
      - 18080:18080
    command: pyspark
    volumes: 
      - ${PWD}:/home/glue_user/workspace/

Then run it like this

docker-compose run --rm pyspark_repl
救赎№ 2025-01-30 15:42:31

问题是Docker组合和pyspark命令在容器中交互。

当您直接在Docker容器中运行Pyspark(如下),通常会期望交互式终端会话。

docker run -it -v ~/.aws:/home/glue_user/.aws -v $WORKSPACE_LOCATION:/home/glue_user/workspace/ -e AWS_PROFILE=$PROFILE_NAME -e DISABLE_SSL=true --rm -p 4040:4040 -p 18080:18080 --name glue_pyspark amazon/aws-glue-libs:glue_libs_4.0.0_image_01 pyspark

将以下说明添加到您的组合中可以解决该问题。

tty: true
stdin_open: true

最终,这是我的撰写文件

services:
  glue_pyspark:
    image: amazon/aws-glue-libs:glue_libs_4.0.0_image_01
    command: ["pyspark"]
    volumes:
      - ~/.aws:/home/glue_user/.aws:ro
      - $WORKSPACE_LOCATION:/home/glue_user/workspace/
    environment:
      - AWS_PROFILE=${AWS_PROFILE}
      - DISABLE_SSL=true
    ports:
      - "4040:4040"
      - "18080:18080"
    tty: true
    stdin_open: true
    deploy:
      restart_policy:
        condition: on-failure

您可以将其称为相同

docker compose --env-file .env.local up -V glue_pyspark

# or in detached mode
docker compose --env-file .env.local up -d -V glue_pyspark

,当您在容器内使用jupyter时,

command: ["/home/glue_user/jupyter/jupyter_start.sh"]

The issue is how Docker Compose and the pyspark command interact within the container.

When you run pyspark directly within a Docker container (like below) it typically expects an interactive terminal session.

docker run -it -v ~/.aws:/home/glue_user/.aws -v $WORKSPACE_LOCATION:/home/glue_user/workspace/ -e AWS_PROFILE=$PROFILE_NAME -e DISABLE_SSL=true --rm -p 4040:4040 -p 18080:18080 --name glue_pyspark amazon/aws-glue-libs:glue_libs_4.0.0_image_01 pyspark

Adding the below instructions to your compose solves the issue.

tty: true
stdin_open: true

This is my compose file

services:
  glue_pyspark:
    image: amazon/aws-glue-libs:glue_libs_4.0.0_image_01
    command: ["pyspark"]
    volumes:
      - ~/.aws:/home/glue_user/.aws:ro
      - $WORKSPACE_LOCATION:/home/glue_user/workspace/
    environment:
      - AWS_PROFILE=${AWS_PROFILE}
      - DISABLE_SSL=true
    ports:
      - "4040:4040"
      - "18080:18080"
    tty: true
    stdin_open: true
    deploy:
      restart_policy:
        condition: on-failure

finally, you can call it like this

docker compose --env-file .env.local up -V glue_pyspark

# or in detached mode
docker compose --env-file .env.local up -d -V glue_pyspark

The same applies when you use jupyter inside of the container

command: ["/home/glue_user/jupyter/jupyter_start.sh"]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文