kubernetes: Pod does not work as expected if multiple containers in one pod

  1. Create a pod3.yaml
gyliu@mesos008:~/gc/kubernetes$ cat examples/walkthrough/pod3.yaml
apiVersion: v1beta1
id: storage
desiredState:
  manifest:
    version: v1beta1
    id: storage
    containers:
      - name: gyliu1
        image: dockerfile/redis
        volumeMounts:
            # name must match the volume name below
          - name: redis-persistent-storage
            # mount path within the container
            mountPath: /data/redis/1
            readOnly: true
    containers:
      - name: gyliu2
        image: dockerfile/redis
        volumeMounts:
            # name must match the volume name below
          - name: redis-persistent-storage
            # mount path within the container
            mountPath: /data/redis/2
    volumes:
      - name: redis-persistent-storage
        source:
          emptyDir: {}
  1. Create Pod based on pod3.yaml
gyliu@mesos008:~/gc/kubernetes$ cluster/kubecfg.sh list pods
Name                Image(s)                                                                            Host                                                                 Labels              Status
----------          ----------                                                                          ----------                                                           ----------          ----------
storage             dockerfile/redis,dockerfile/redis                                                   kubernetes-minion-2.c.concrete-fusion-775.internal/130.211.176.116                       Running
  1. kubecfg report the pod was created successfully on kubernetes-minion-2
  2. Logon to kubernetes-minion-2 and check the container
root@kubernetes-minion-2:/home/gyliu# docker ps
CONTAINER ID        IMAGE                                     COMMAND                CREATED             STATUS              PORTS                    NAMES
efd5e88bc66f        dockerfile/redis:latest                   "redis-server /etc/r   3 minutes ago       Up 3 minutes                                 k8s_gyliu1.279e4161_storage.default.etcd_2cd9bfac-76ca-11e4-9901-42010af05ac7_438ca02e                                                      
d7bc08ffb31b        kubernetes/pause:latest                   "/pause"               3 minutes ago       Up 3 minutes                                 k8s_net.dbcb7509_storage.default.etcd_2cd9bfac-76ca-11e4-9901-42010af05ac7_4e2adc24           
  1. Only gyliu1 was created but gyliu2 was not created.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

@gyliu513 Hello, I have encounted the same problem. In my case, a pod has three containers, all of the have different roles, but because they share the same tech stack (based on jetty platform), when started, they all listen 8080 port. Then I found only one container running, the other two crash. If I don’t want to change the listen ports, does it mean I have no way to solve this problem, even in the newest k8s version? Wish geting your help, thanks.