I want to mount directory from SourceContaner to ServerContainer.
ServerContainer:
FROM php:7.2-apache
RUN a2enmod rewrite
# /var/www/html is apache document root.
SourceContaner:
FROM alpine:3.7
# Copy local code to the container image.
COPY ./my_src /var/www/html/my_src
VOLUME /var/www/html/my_src
And, yaml is below.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test
spec:
...snip...
spec:
containers:
- name: server-container
image: "Server Container image"
ports:
...snip...
volumeMounts:
- name: src-volume
mountPath: /var/www/html/my_src
- name: src-container
image: "Source Container Image"
volumes:
- name: src-volume
hostPath:
path: /var/www/html/my_src
But Source Container "CrashLoopBackOff" occured. and nothing log is output.
This is not a feature of Kubernetes. There is an old FlexVolume plugin that implements the same behavior as Docker, but it isn’t recommended. You can use an initContainer to copy from the data container into a volume like an emptyDir.