Complete the code to define an init container in a Pod spec.
initContainers:
- name: init-myservice
image: busybox
command: ["[1]", "-c", "echo Init container running"]The init container uses sh to run the shell command.
Complete the code to specify the init container image.
initContainers:
- name: init-db
image: [1]The init container uses the lightweight busybox:1.35 image for initialization tasks.
Fix the error in the init container command to run a shell script.
initContainers:
- name: setup
image: busybox
command: ["[1]", "-c", "echo Setup complete"]The sh shell is available in busybox and correctly runs the command.
Fill both blanks to define an init container that waits for a file before starting the main container.
initContainers: - name: wait-for-file image: busybox command: ["[1]", "-c", "until test -f /tmp/ready; do [2] 1; done"] containers: - name: main-app image: myapp volumeMounts: - name: shared-data mountPath: /tmp volumes: - name: shared-data emptyDir: {}
The init container uses sh to run the shell loop and sleep to wait between checks.
Fill all three blanks to create an init container that creates a directory and sets permissions before the main container starts.
initContainers:
- name: setup-dir
image: busybox
command: ["[1]", "-c", "mkdir -p /data [3] [2] 777 /data && echo Directory ready"]
volumeMounts:
- name: data-volume
mountPath: /data
containers:
- name: app
image: myapp
volumeMounts:
- name: data-volume
mountPath: /data
volumes:
- name: data-volume
emptyDir: {}The init container uses sh to run commands, chmod to set permissions, and && to chain commands.