Kubernetes 101 : Running multiple containers inside a Pod

The below Yaml file is the configuration of a pod with one container:

we create our pod using the below command:

A two containers pod:

Below is a Yaml configuration file of a pod with two containers ( nginx and debian ):

We create our "nginx-pod" using the below command:

Running a command inside a container:

Because we have two containers inside the above pod, we would need to specify in which container we want to execute our commands.
We can do so using the "-c container_name" option, as we can see below:

From the "debiancontainer, we could run the below command to connect to the "nginx" container using the "localhost" network interface:

We could check the logs of "nginx" container, to see the details of the connection coming from the "debian" container, using the below command:


Leave as a comment: