While diving into Docker, Google Cloud and Kubernetes, and without clearly understanding all three of them yet, it seems to me these products are overlapping, yet they\'re not c
Docker Compose:
In a docker-compose.yml
file each entry can optionally get docker-compose
to build an image. each entry can represent a single container we want to build and each entry defines the networking requirements or ports.
Kubernetes:
Kubernetes expects all images to already be built and there is one config file per object we want to create and we have to manually setup up all networking.
So we ensure our image is hosted on Docker Hub, make one config file to create the container and one config file to set up networking.
Docker-Compose is a deployment file that predefined one or more container with its environment such as volumes, networking, a command to run and so on.
Kubernetes, on the other hand, is a system that orchestrates docker containers and other microservices by and makes them scaled and reliable across multiple nodes
Just to give you an analogy; while Docker composer is like a captain of a privately-owned cargo ship who can load and arrange multiple containers in the ship, Kubernetes is like the harbour control system which manages multiple ships; captains; containers loadings and unloadings; communication between ships; their travel schedules; etc.
Docker compose: docker containers can be run directly with out assist of any yaml file. But with assist of Docker compose tool container properties can be defined inside a file called docker-compose.yml file. please find the below sample yml file for more details.
version: "3.7"
services:
redis:
image: redis:latest
deploy:
replicas: 1
configs:
- my_config
- my_other_config
configs:
my_config:
file: ./my_config.txt
my_other_config:
external: true
name of image, number of replicas, etc.. can be configured through yml file.
Kubernetes: This is container management platform run on top of Docker built by google. Docker swam is another container management platform built by docker itself. Kubernetes also provide facility to save configuration related to pods(correspond to container in docker) in yaml file like docker compose. example yaml file
apiVersion: v1
kind: Pod
metadata:
name: rss-site
labels:
app: web
spec:
containers:
- name: front-end
image: nginx
ports:
- containerPort: 80
- name: rss-reader
image: nickchase/rss-php-nginx:v1
ports:
- containerPort: 88
here also images, ports to be opened and pod to host port mappings, etc.. can be given. like docker compose, kubectl apply -f is the command to run this file.
In addition to @yamenk's answer, I'd like to add a few details here which might help people with their journey of understanding Kubernetes.
docker-compose
: is a tool that takes a YAML file which describes your multi-container application and helps you create, start/stop, remove all those containers without having to type multiple docker ...
commands for each container.Kubernetes
: is a platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. What? Docker compose is the tool where we can run and execute multiple interlinked containers once at a time instead of creating or execution of docker command for each container.
While is kubernetes is the platform where we can manage the multiple containers , load balancer and much more.