如何设置Kubernetes启动的容器的工作目录

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

是的,通过容器规范的workingDir字段。 下面是一个复制控制器的示例,其中包含一个将workingDir设置为/workdir的nginx容器:

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