What's the difference between Docker Compose and Kubernetes?

后端 未结 12 1980
南笙
南笙 2021-01-29 16:50

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

12条回答
  •  清酒与你
    2021-01-29 17:41

    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.

提交回复
热议问题