AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 892577
Accepted
A X
A X
Asked: 2018-01-17 17:07:46 +0800 CST2018-01-17 17:07:46 +0800 CST 2018-01-17 17:07:46 +0800 CST

Kubernetes - 如何将 docker run 命令行参数映射到 kubectl 命令行

  • 772

我需要在 Kubernetes 中运行这个 Docker 命令:

docker run -p 8080:8080 sagemath/sagemath sage -notebook

我可以映射除“-notebook”以外的所有内容-有人知道该怎么做吗?

这是我到目前为止所拥有的,当然它不起作用,因为“-notebook”没有正确转换为 kubectl:

kubectl run --image=sagemath/sagemath sage --port=8080 --type=LoadBalancer -notebook
docker
  • 3 3 个回答
  • 11300 Views

3 个回答

  • Voted
  1. Best Answer
    Radek 'Goblin' Pieczonka
    2018-01-17T22:25:23+08:002018-01-17T22:25:23+08:00

    当您为您的 sage 定义 pod 规格时,您可以同时定义command一个args数组,所以对您来说就像

    command: sage
    args:
    - -notebook
    

    用于启动kubectl run

    Usage:
      kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...] [options]
    

    所以尝试使用--分隔符运行:kubectl run --image=sagemath/sagemath --port=8080 --type=LoadBalancer -- sage -notebook

    • 9
  2. Gabriel Miretti aka gmiretti
    2018-01-18T04:34:11+08:002018-01-18T04:34:11+08:00

    --成功了。这意味着 kubectl 不会将以下开头的字符串解析为 kubectl 参数-

    所以你运行该容器执行:

    kubectl run --image=sagemath/sagemath --port=8080 sage -- -notebook
    

    如果您想要 GKE 上的公共 IP,您应该公开执行的容器:

    kubectl expose deploy sage --type=LoadBalancer --port=8080
    

    您可以在 EXTERNAL-IP 列kubectl get service的行中运行公共 IPsage

    • 1
  3. Blue Clouds
    2019-06-06T20:51:13+08:002019-06-06T20:51:13+08:00
    command: sage notebook
    args:
    

    对于此类情况

    k run --image=sagemath/sagemath --port=8080 --command=true -- sage notebook
    

    --command=false 如果存在 true 和额外参数,请将它们用作容器中的“命令”字段,而不是默认的“参数”字段。

    • 0

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve