<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/" rel="noreferrer">Kubernetes documentation</a> on setting environment variables of a container only include examples of new environment variables.</p>

<p>This approach does not work when I try to extend an existing environment variable PATH:</p>

<pre><code>kind: Pod
apiVersion: v1
spec:
  containers:
    - name: blah
      image: blah
      env:
        - name: PATH
          value: "$PATH:/usr/local/nvidia/bin"
</code></pre>

<p>The created pod keeps crashing with</p>

<pre><code>BackOff       Back-off restarting failed container
FailedSync    Error syncing pod
</code></pre>

<p>Any recommendations as to how I could extend the PATH environment variable?</p>

<p>If you only need this path declaration for the command you are running with, you can add it to <code>containers</code> section, under <code>args</code></p>

<p>Example:</p>

<pre><code>spec:
  containers:
  - name: blah
    image: blah
    args:
    - PATH="$PATH:/usr/local/nvidia/bin" blah
</code></pre>

<p>If you do not have args specified in your yaml, you probably have a CMD specified in your Dockerfile that will just run your container with the command automatically. Thus you can add the following to your Dockerfile.</p>

<pre><code>CMD ["PATH=$PATH:/usr/local/nvidia/bin", "blah"]
</code></pre>

<p>If you want this to be in your container in general, you would have to add to the .profile or .bashrc file of the user within the container you are using. This will probably involve creating a new image with these new files baked in.</p>
