Reputation: 325
I have a Pod with two containers, Nginx and Rails. I want to share the public folder from the rails to the nginx container, but the public contains already files, I don't want the folder be empty.
Is there a way with a shared-volume?
I tried:
- name: rails-assets
hostPath:
path: /app/public
But im getting this error:
Error: failed to start container "nginx": Error response from daemon: {"message":"error while creating mount source path '/app/public': mkdir /app: read-only file system"}
Error syncing pod
Back-off restarting failed container
Thanks,
Upvotes: 0
Views: 1519
Reputation: 325
I fixed that problem creating a shared-volument shared-assets/
on the rails app. On the rails dockerfile I created a ENTRYPOINT with a bash script to copy the public/
files on the shared-assets/
folder. With this I can see the files now on the Nginx Container.
---
kind: Deployment
apiVersion: apps/v1beta1
metadata:
name: staging-deployment
spec:
replicas: 1
revisionHistoryLimit: 2
template:
metadata:
labels:
app: staging
spec:
containers:
- name: staging
image: some/container:v5
volumeMounts:
- mountPath: /var/run/
name: rails-socket
- mountPath: /app/shared-assets
name: rails-assets
- name: nginx
image: some/nginx:latest
volumeMounts:
- mountPath: /var/run/
name: rails-socket
- mountPath: /app
name: rails-assets
imagePullSecrets:
- name: app-backend-secret
volumes:
- name: rails-socket
emptyDir: {}
- name: rails-assets
emptyDir: {}
And the script ENTRYPOINT:
cp -r /app/public/ /app/shared-assets/
Upvotes: 3