0

I am trying to launch an application with openshift and am running into this issue with mariadb. I found this thread (Kubernetes: mysqld Can't create/write to file '/var/lib/mysql/is_writable' (Errcode: 13 - Permission denied)) but could not figure out where to put the initContainer. Here is my docker container and openshift script.

Error log:

2022-11-18 02:22:42+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.9.4+maria~ubu2204 started.
2022-11-18 02:22:42+00:00 [Note] [Entrypoint]: Initializing database files
2022-11-18  2:22:42 0 [Warning] Can't create test file /var/lib/mysql/backend.lower-test
2022-11-18  2:22:42 0 [ERROR] mariadbd: Can't create/write to file './ddl_recovery.log' (Errcode: 13 "Permission denied")
2022-11-18  2:22:42 0 [ERROR] DDL_LOG: Failed to create ddl log file: ./ddl_recovery.log
2022-11-18  2:22:42 0 [ERROR] Aborting
apiVersion: v1
items:
- apiVersion: v1
  kind: Pod
  metadata:
    labels:
      app: application
      name: backend
    name: backend
  spec:
    containers:
    - env:
      image: db_image
      name: backend
      ports:
      - containerPort: 3306
        name: backend
      volumeMounts:
      - mountPath: /var/lib/root
        name: backend-volume
    volumes:
    - name: backend-volume
      persistentVolumeClaim:
        claimName: backend-claim
- apiVersion: v1
  kind: Pod
  metadata:
    labels:
      app: application
      name: flask
    name: flask
  spec:
    containers:
    - env:
      - name: IP_ADDR
        value: ${mariadb_ip_addr}
      image: flask_image
      name: flask
      ports:
      - containerPort: 5000
        name: flask
      resources:
        limits:
          cpu: "0.5"
- apiVersion: v1
  kind: Service
  metadata:
    labels:
      app: application
      name: flask
    name: flask
  spec:
    ports:
    - port: 5000
    selector: 
      name: flask
- apiVersion: v1
  kind: Service
  metadata:
    labels: 
      app: application
      name: backend
    name: backend
  spec:
    ports:
    - port: 3306
    selector:
      name: backend
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata: 
    labels: 
      app: application
    name: backend-claim
  spec:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 10Mi
kind: List
metadata: {}
FROM mariadb
LABEL description = "This is my mariadb dockerfile"
EXPOSE 3306
ENV MARIADB_ROOT_PASSWORD=Password123!
ENV MARIADB_DATABASE demo
USER root
COPY ./sql-scripts/ /docker-entrypoint-initdb.d/ 
Rajesh Patel
  • 53
  • 1
  • 9
  • The `/var/lib/root` needs to be `/var/lib/mysql`. Your env variables of the dockerfile could be in your `yaml` file. Can you put your sql-scripts into a volume and pass this as to the `mountPath` or `/docker-entrypoint-initdb.d`. – danblack Nov 18 '22 at 02:51
  • @danblack so should the mountpath be `/docker-entrypoint-initdb.d`? Also, do you know if there is a way to put the sql-scripts into a volume within my yaml file or must it be done with the cli? – Rajesh Patel Nov 18 '22 at 03:50

0 Answers0