initContainer和Kubernetes中的容器之间的区别

I noticed in a deployment file there are two fields for containers like initContainers and containers and looks confusing to me and I search through the internet but can't understand. Could anyone please tell me the difference between initContainers and containers and how we use them together?

例如

  containers:
  - name: php
    image: php:7-fpm
    volumeMounts:
    - name: dir
      mountPath: /dir
  initContainers:
  - name: install
    image: busybox
    volumeMounts:
    - name: dir
      mountPath: /dir
    command:
    - wget
    - "-O"
    - "/dir/index.php"
    - https://raw.githubusercontent.com/videofalls/demo/master/index.php

非常感谢,并预先感谢!!

评论
喵oo
喵oo

Init Containers run before the main container runs. Normally init containers are used to ensure the server environment is ready for your application to start to run.

Go through the detailed official document for better understanding

点赞
评论