I have a Helm chart that deploys a docker container containing MySQL. I want to also do a Helm test (which is really just another deployment of a container that you can tell it to run commands on). The two things I need installed are:
I tried using the bats/bats
Docker container but it throws the error:
Error: failed to start container "db-test": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: "/bin/bash": stat /bin/bash: no such file or directory": unknown
How would I make a Dockerfile
that would have installed the software I need to run this test?
My Current Test YAML
{{- if .Values.db.enabled }}
apiVersion: v1
kind: Pod
metadata:
name: "{{ .Release.Name }}-credentials-test"
namespace: {{ quote .Values.metadata.namespace }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: {{ .Release.Name }}-credentials-test
image: "bats/bats:1.2.1"
imagePullPolicy: "IfNotPresent"
env:
- name: MYSQL_HOST
value: {{ include "db-application.name" . }}
- name: MYSQL_PORT
value: "3306"
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: db-credentials
key: db-username
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: db-password
command:
- /bin/bash
- -ec
- |
mysql --host=$MYSQL_HOST --port=$MYSQL_PORT --user=$MYSQL_USER --password=$MYSQL_PASSWORD
restartPolicy: Never
{{- end }}
Essentially, I need a container from which I can run this command:
/bin/bash -ec mysql --host=$MYSQL_HOST --port=$MYSQL_PORT --user=$MYSQL_USER --password=$MYSQL_PASSWORD
question from:
https://stackoverflow.com/questions/65947207/how-can-i-make-a-docker-container-that-can-run-a-bash-command-and-has-mysql-inst 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…