Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rk295/33eb4f973f51e9dc7dfb1319d8c6aaea to your computer and use it in GitHub Desktop.
Save rk295/33eb4f973f51e9dc7dfb1319d8c6aaea to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Pod
metadata:
labels:
app: nginx
name: nginx-test
namespace: default
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
volumeMounts:
- mountPath: /usr/share/nginx/html
name: shared-volume
- image: ubuntu
imagePullPolicy: Always
name: ubuntu
command: ["/usr/bin/tail"]
args: ["-f", "/dev/null"]
volumeMounts:
- mountPath: /shared
name: shared-volume
volumes:
- name: shared-volume
emptyDir: {}
@rk295
Copy link
Author

rk295 commented Dec 4, 2017

The two containers - nginx and ubuntu - spin up inside the same pod and share a filesystem between them. This is mounted under /shared inside the ubuntu container and /usr/share/nginx/html in the nginx container. If you port forward port 80 to the nginx container and try to web browse to it you will see a 403 because there is no index.html. If you then exec a shell into the ubuntu container and run:

echo "hello" > /shared/index.html

Then reload the page served by nginx, you'll see a web page with the string hello on it. Proving the two containers are sharing a filesystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment