skip to Main Content

I have installed Worpress in Rancher, (docker.io/bitnami/wordpress:5.3.2-debian-10-r43) I have to make wp-config writable but I get stuck, when get shell inside this pod to log as root :

kubectl exec -t -i --namespace=annuaire-p-brqcw annuaire-p-brqcw-wordpress-7ff856cd9f-l9gf7 bash

I cannot login to root, no password match with Bitnami WordPress installation.

wordpress@annuaire-p-brqcw-wordpress-7ff856cd9f-l9gf7:/$ su root
Password: 
su: Authentication failure

What is the default password, or how to change it ?

I really need your help!

2

Answers


  1. The WordPress container has been migrated to a "non-root" 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 changing USER 1001 to USER root in the Dockerfile.

    No writing permissions will be granted on wp-config.php by default.

    This means that the only way to run it as root user is to create own Dockerfile and changing user to root.

    However it’s not recommended to run those containers are root for security reasons.

    Login or Signup to reply.
  2. The simplest and most native Kubernetes way to change the file content on the Pod’s container file system is to create a ConfigMap object from file using the following command:

    $ kubectl create configmap myconfigmap --from-file=foo.txt
    $ cat foo.txt
    foo test
    

    (Check the ConfigMaps documentation for details how to update them.)

    then mount the ConfigMap to your container to replace existing file as follows:
    (example requires some adjustments to work with WordPress image):

    apiVersion: v1
    kind: Pod
    metadata:
      name: mypod
    spec:
      containers:
      - name: mypod
        image: nginx
        volumeMounts:
        - name: volname1
          mountPath: "/etc/wpconfig.conf"
          readOnly: true
          subPath: foo.txt
      volumes:
      - name: volname1
        configMap:
          name: myconfigmap
    

    In the above example, the file in the ConfigMap data: section replaces original /etc/wpconfig.conf file (or creates if the file doesn’t exist) in the running container without necessity to build a new container.

    $ kubectl exec -ti mypod -- bash
    root@mypod:/# ls -lah /etc/wpconfig.conf
    -rw-r--r-- 1 root root 9 Jun  4 16:31 /etc/wpconfig.conf
    root@mypod:/# cat /etc/wpconfig.conf
    foo test
    

    Note, that the file permissions is 644 which is enough to be readable by non-root user.

    BTW, Bitnami Helm chart also uses this approach, but it relies on the existing configMap in your cluster for adding custom .htaccess and persistentVolumeClaim for mounting WordPress data folder.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search