Can we have a single container with multiple image like nginx + Redis + alpine?

12/25/2020

We have to create Pod with single container which has to use the image redis + nginx + memcached. Then below are questions:

Is this possible? if yes, how to create it,. Any way interactive or yaml based ? please share the yaml file if possible

-- Parth Gandhi
docker
kubernetes

2 Answers

12/25/2020

Is this possible?

Not...really? A container boots from a single image. On the other hand, you can certainly create a single image that includes all of those services:

  • Using a multi-stage build you could combine content from multiple images, but you would be merging it into a single image.

  • You could just install them your on top of an Alpine base image.

In either case, your pod would probably still have multiple containers.

-- larsks
Source: StackOverflow

12/25/2020

Kubernetes allows pods to have multiple containers running as sidecars, each running as an independent process but having the capability to work together. The different containers that form a pod are scheduled on the same VM.

The ideal way to achieve what you need would be to have individual containers for Redis, Nginx and Memcached. These will then need to be scheduled as a pod.

You can refer to this for basic understanding - https://kubernetes.io/docs/concepts/workloads/pods/#how-pods-manage-multiple-containers

-- akaHuman
Source: StackOverflow