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
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.
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:
(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):
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.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 WordPressdata
folder.