Robin的主页

Tutorials

The best way to learn it is just to follow the OFFICIAL tutorial.

Docker

Basic Concepts:

  • Dockerfile will define what goes on in the environment inside your container.
  • Services are really just “containers in production.” A service only runs one image, but it codifies the way that image runs—what ports it should use, how many replicas of the container should run so the service has the capacity it needs, and so on. 
  • A swarm is a group of machines that are running Docker and joined into a cluster.
  • A stack is a group of interrelated services that share dependencies, and can be orchestrated and scaled together.
  • Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration. - Overview of Docker Compose

基本概念:

  • Dockerfile,镜像Image描述文件
  • Repository仓库,存放镜像的地方
  • Container容器,是实例化的Image
  • Service服务,运行时的Container
  • Swarm集群,一组运行Docker并连接到同一集群的机器
  • Stack服务组,一组相关的、共享依赖的、可共编的和扩容的Services

Save Docker Images

You will need to save the docker image as a tar file:

docker save -o <save image to path> <image name>

Then copy your image to a new system with regular file transfer tools such as cp or scp. After that you will have to load the image into docker:

docker load -i <path to image tar file>

from How to copy docker images from one host to another without via repository?

Some terminology

image vs. container

image: A static, immutable object. This is the thing you build when you run docker build using a Dockerfile. An image is not a thing that runs.

Images are composed of layers. an image might have only one layer, or it might have many layers.

container: A running thing. It uses an image as its starting template.


Kubernetes

To make use of this new model of deployment, applications need to be packaged in a way that decouples them from individual hosts: they need to be containerized. Containerized applications are more flexible and available than in past deployment models, where applications were installed directly onto specific machines as packages deeply integrated into the host. Kubernetes automates the distribution and scheduling of application containers across a cluster in a more efficient way.

Basic Concepts:

  • Cluster
    • A Kubernetes cluster consists of two types of resources:
      • The Master coordinates the cluster
      • Nodes are the workers that run applications
    • The Master is responsible for managing the cluster.
    • A node is a VM or a physical computer that serves as a worker machine in a Kubernetes cluster.
    • The nodes communicate with the master using the Kubernetes API.
  • Pods
    • A Pod always runs on a Node.
    • A Pod is a Kubernetes abstraction that represents a group of one or more application containers (such as Docker or rkt), and some shared resources for those containers. Those resources include:
      • Shared storage, as Volumes
      • Networking, as a unique cluster IP address
      • Information about how to run each container, such as the container image version or specific ports to use
    • A Pod is the basic building block of Kubernetes–the smallest and simplest unit in the Kubernetes object model that you create or deploy.
  • Services
    • A Service routes traffic across a set of Pods.
    • Services are the abstraction that allow pods to die and replicate in Kubernetes without impacting your application.
    • Discovery and routing among dependent Pods (such as the frontend and backend components in an application) is handled by Kubernetes Services.
  • Labels
    • Services match a set of Pods using labels and selectors, a grouping primitive that allows logical operation on objects in Kubernetes.
  • Scaling
    • Scaling is accomplished by changing the number of replicas in a Deployment.
    • Scaling up a Deployment will ensure new Pods are created and scheduled to Nodes with available resources. Scaling down will reduce the number of Pods to the new desired state.
  • Deployments
    • A Deployment controller provides declarative updates for Pods and ReplicaSets.
  • Rolling updates
    • Rolling updates allow Deployments’ update to take place with zero downtime by incrementally updating Pods instances with new ones. The new Pods will be scheduled on Nodes with available resources

相关资料

- - - - - -
written by 陈烨彬 Robin Chen , and published under (CC) BY-NC-SA.