I'm learning Kubernetes. I'm trying to mapping equivalent concept from Kubernetes to Docker. For example: I have a following docker-compose.yml
db:
container_name: db
image: postgres:latest
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: 1234
app:
container_name: app
build: .
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- ".:/webapp"
env_file:
- ./.env.docker_compose
links:
- db
This docker-compose.yml
has two components: db and app. There are 2 ways for understanding. I don't know which one is true and which one is wrong.
Please tell me which one is true. The same question for Deployment
and Service
. How can I map to docker concept.
Thanks
A pod being a group of one or more container, your docker-compose would by default mimick one pod. (so your second interpretation)
But with docker swarm mode, you can make sure those two container are in their own "pod" (as a group of one container) with constraints.
With dockerfile v3, you have for instance placement (also seen in docker service create
)
version: '3'
services:
db:
image: postgres
deploy:
placement:
constraints:
- node.role == manager
- engine.labels.operatingsystem == ubuntu 14.04