Pods with more than one container

Our examples have been simple so far, with a single container in a Pod. A Pod can have more than one container at a time, and the command to get the logs can specify which container to use. If there is only one container, you don’t need to specify which one to use.

If you need to specify a specific container, you can do so with either the -c option, or by adding it onto the logs command. For example, if you had a Pod named webapp with two containers, flask and background, and you wanted to see the logs from the background container, you could use the kubectl logs webapp background or kubectl logs webapp -c background commands.

Likewise, there's a shortcut for defining Pods and containers within a deployment. ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.