本文介绍了Kubernetes相当于'docker run -it'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个docker映像,并且正在使用以下命令来运行它.

I have one docker image and I am using following command to run it.

docker run -it -p 1976:1976 --name demo demo.docker.cloud.com/demo/runtime:latest

我想在Kubernetes中运行相同的代码.这是我当前的yaml文件.

I want to run the same in Kubernetes. This is my current yaml file.

apiVersion: v1
kind: Deployment
metadata:
  name: demo-deployment
  labels:
    app: demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo
  template:
    metadata:
      labels:
        app: demo
    spec:
      containers:
      - name: demo
        image: demo.docker.cloud.com/demo/runtime:latest
        ports:
        - containerPort: 1976
        imagePullPolicy: Never

此yaml文件涵盖标志"-it"以外的所有内容.我找不到它的Kubernetes等效项.这个你能帮我吗.谢谢

This yaml file covers everything except flag "-it". I am not able to find its Kubernetes equivalent. Please help me out with this. Thanks

推荐答案

查看 API参考中的容器定义,等效选项为stdin: truetty: true.

(我从事的所有应用程序都不曾需要此功能; stdin:的文档讨论了从容器中的stdin读取"以及您在Deployment中运行的典型的服务器类型进程)根本没读过stdin.)

(None of the applications I work on have ever needed this; the documentation for stdin: talks about "reads from stdin in the container" and the typical sort of server-type processes you'd run in a Deployment don't read from stdin at all.)

这篇关于Kubernetes相当于'docker run -it'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-01 13:50