clearcontainers / runtime

OCI (Open Containers Initiative) compatible runtime using Virtual Machines
Apache License 2.0
590 stars 70 forks source link

[question]How to join a container into a running pod? #819

Open WeiZhang555 opened 6 years ago

WeiZhang555 commented 6 years ago

I've tried your solution and successfully booted a container via cc-runtime + docker, but I have a question, if I started a container with "docker run", then I got a VM(/pod), is that possible to add a new container into this VM with something like "docker run "? If true, how?

sboeuf commented 6 years ago

Hi @WeiZhang555, what you're asking for is not possible through Docker because Docker does not have the concept of pod. Thus, when we start a container with Docker, it is only one container per pod(VM). You can achieve several containers per pod by using:

WeiZhang555 commented 6 years ago

@sboeuf Thanks for your response! So what's the public interface of cc-runtime for creating a pod with several container? Does it need an extended "config.json" and "bundle" beyond the OCI specification? I would appriciate you if you could provide a workable example, I tried to search the documentation, but find nothing. :smiley:

sboeuf commented 6 years ago

@WeiZhang555 I am sorry but I don't have such low level example. I use CRIO usually if I want to try this kind of use case. But yes you're right, we are relying on some extra fields in the config.json (extending OCI spec), which allow us to determine if this is a pod or a container. Take a look at https://github.com/containers/virtcontainers/blob/master/pkg/oci/utils.go and https://github.com/kubernetes-incubator/cri-o/blob/master/pkg/annotations/annotations.go.

WeiZhang555 commented 6 years ago

@sboeuf Thanks! I'll find more information in codes, and figure out how to do it :smile:

sboeuf commented 6 years ago

@WeiZhang555 sounds good :)