I have create a docker image for my wordpress application with just this
FROM wordpress:php7.4-apache
COPY . /var/www/html
after i have push my image on my private repo. When i run my new image the file of my custom wordpress are well in the /var/www/html
.
but when i create a deploy in kubernetes with pvc my file on path /var/www/html is replace by the file from the wordpress:php7.4-apache image
i create my pvc like this
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
namespace: custom
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
and my deploy look like
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: custom
name: wordpress
labels:
app: wordpress
spec:
replicas: 1
selector:
matchLabels:
app: wordpress
template:
metadata:
labels:
app: wordpress
spec:
containers:
- image: privaterepo.azurecr.io/custom:latest
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: mysqlhost
- name: DB_HOST
value: mysqlhost
- name: WORDPRESS_DB_USER
value: mysqluser
- name: DB_USER
value: mysqluser
- name: WORDPRESS_DB_PASSWORD
value: mysqlpassword
- name: DB_PASS
value: mysqlpassword
- name: WORDPRESS_DB_NAME
value: dbname
- name: DB_NAME
value: dbname
- name: WORDPRESS_TABLE_PREFIX
value: wp
ports:
- containerPort: 80
name: client
volumeMounts:
- name: wordpress-persistent-storage
mountPath: /var/www/html
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim
Based on everything that was discussed in comments providing the answer for next generations :)
As per monachus/wordpress
What's wrong with Wordpress's Docker image?
The container shipped by Wordpress copies over the contents of /usr/src/wordpress to /var/www/html when the container is first created, but only if no content already exists in /var/www/html. This means that if you've already deployed the container and have a persistent volume mounted at that location, you can upgrade your container from 4.7.4 to 4.8.1, and although it claims to be 4.8.1, nothing happens.
Correct Dockerfile
should contain /usr/src/wordpress
path instead of /var/www/html
FROM wordpress:php7.4-apache
COPY . /usr/src/wordpress