...

/

Running Multiple Containers in a Single Pod

Running Multiple Containers in a Single Pod

Learn to run a Pod with multiple containers.

Anatomy of a Pod

  • Pods are designed to run multiple cooperative processes that should act as a cohesive unit. Those processes are wrapped in containers.

  • All the containers that form a Pod are running on the same machine. A Pod cannot be split across multiple nodes.

  • All the processes (containers) inside a Pod share the same set of resources, and they can communicate with each other through localhost. One of those shared resources is storage.

  • A volume (think of it as a directory with shareable data) defined in a Pod can be accessed by all the containers, therefore allowing them all to share the same data.

We’ll explore storage and volumes in more depth later on. For now, let’s look at the go-demo-2.yml specification.

Press + to interact
apiVersion: v1
kind: Pod
metadata:
name: go-demo-2
labels:
type: stack
spec:
containers:
- name: db
image: mongo:3.3
- name: api-1
image: vfarcic/go-demo-2
env:
- name: DB
value: localhost
- name: api-2
image: vfarcic/go-demo-2
env:
- name: DB
value: localhost

The db.yml file defines a Pod with two ...

Access this course and 1400+ top-rated courses and projects.