How to set the workdir of a container launched by Kubernetes

4/14/2016

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

-- pditommaso
docker
kubernetes

1 Answer

4/14/2016

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
-- ghodss
Source: StackOverflow