使用Kubernetes启动容器时是否可以设置工作目录?
答案 0 :(得分:32)
是的,通过container spec的workingDir
字段。这是一个带有nginx容器的复制控制器示例,workingDir
设置为/workdir
:
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx
spec:
replicas: 1
template:
metadata:
labels:
name: nginx
spec:
containers:
- name: nginx
image: mynginximage
workingDir: /workdir