如何设置Kubernetes启动的容器的工作目录 [英] How to set the workdir of a container launched by Kubernetes

查看:73
本文介绍了如何设置Kubernetes启动的容器的工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Kubernetes启动容器时是否可以设置工作目录?

Is it possible to set the working directory when launching a container with Kubernetes ?

推荐答案

是的,通过

Yes, through the workingDir field of the container spec. Here's an example replication controller with an nginx container that has workingDir set to /workdir:

apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: nginx
    spec:
      containers:
        - name: nginx
          image: mynginximage
          workingDir: /workdir

这篇关于如何设置Kubernetes启动的容器的工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆