<p>Getting the following when trying to attach visual studio code to a WordPress pod (using the kubernetes extension):</p>
<p><code>An error occurred attaching to the container</code></p>
<p>With the following showing up in the terminal:</p>
<pre><code>[3 ms] Remote-Containers 0.166.0 in VS Code 1.55.0 (c185983a683d14c396952dd432459097bc7f757f).
[48 ms] Start: Resolving Remote
[51 ms] Start: Run: kubectl exec -it wp-test-2-wordpress-65859bfc97-qtr9w --namespace default --container wordpress -- /bin/sh -c VSCODE_REMOTE_CONTAINERS_SESSION='5875030e-bcef-47a6-ada5-7f69edb5d9091617678415893' /bin/sh
[56 ms] Start: Run in container: id -un
[279 ms] 1001
[279 ms] Unable to use a TTY - input is not a terminal or the right kind of file
id: cannot find name for user ID 1001
[279 ms] Exit code 1
[281 ms] Command in container failed: id -un
</code></pre>
<p>I have no such problem doing the exact same operation on any other helm release. Only with Bitnami WordPress helm releases.</p>

Nomnom
<p>That is because the Bitnami WordPress image (version <code>9.0.0</code>) was migrated to a &quot;non-root&quot; user approach. From now on, both the container and the Apache daemon run as user <code>1001</code>.</p>
<p>You can find more information in the <a href="https://github.com/bitnami/charts/tree/master/bitnami/wordpress#to-900" rel="nofollow noreferrer">Bitnami WordPress documentation</a>:</p>
<blockquote>
<p>The Bitnami WordPress image was migrated to a &quot;non-root&quot; user approach. Previously the container ran as the root user and the Apache daemon was started as the daemon user. From now on, both the container and the Apache daemon run as user 1001. You can revert this behavior by setting the parameters securityContext.runAsUser, and securityContext.fsGroup to 0. Chart labels and Ingress configuration were also adapted to follow the Helm charts best practices.</p>
</blockquote>
<p>This problem occurs because running the <code>id -un</code> command inside the WordPress Pod causes error:</p>
<pre><code>$ kubectl exec -it my-1-wordpress-756c595c9c-497xr -- bash
I have no name!@my-1-wordpress-756c595c9c-497xr:/$ id -un
id: cannot find name for user ID 1001
</code></pre>
<p>As a workaround, you can run WordPress as a <code>root</code> by setting the parameters <code>securityContext.runAsUser</code>, and <code>securityContext.fsGroup</code> to <code>0</code> as described in the <a href="https://github.com/bitnami/charts/tree/master/bitnami/wordpress#to-900" rel="nofollow noreferrer">Bitnami WordPress documentation</a>.</p>
<p>For demonstration purposes, I only changed the <code>containerSecurityContext.runAsUser</code> parameter:</p>
<pre><code>$ helm install --set containerSecurityContext.runAsUser=0 my-1 bitnami/wordpress
</code></pre>
<p>Then we can check the output of the <code>id -un</code> command:</p>
<pre><code>$ kubectl exec -it my-1-wordpress-7c44f695ff-f9j9f -- bash
root@my-1-wordpress-7c44f695ff-f9j9f:/# id -un
root
</code></pre>
<p>As you can see, the <code>id -un</code> command doesn't cause any problems and therefore we can now successfully connect to the specific container.</p>
<p>I know this workaround is not ideal as there are many advantages to using non-root containers.
Unfortunately, in this case, I don't know of any other workarounds without modifying the Dockerfile.</p>
