1

I'm working on Python Pod to do one main job. However, for a single step, I need different versions of Ruby, so instead of installing all ruby versions in the "main" python container, I was wondering if I can install a version of ruby per container and then use one of those ruby containers as a sidecar. The idea comes from this use case of the Ruby Docker image

docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp ruby:2.5 ruby your-daemon-or-script.r

so I was wondering if we can translate that line to "kubernetes lingo"

1

You can run any docker image as a second container within a pod. You will see that pod.spec.containers is a list which you can run multiple containers (with different docker images/commands/ports/etc).

What you do with that second container is up to you. If you main python app needs to make a call to that container, the ruby container could run a web server. Pods share the same network so your python app could call http://localhost:8080 (or whereever your ruby application exposes a http server).

You can also share a volume between the two containers, so they share the same file system. Read more about that here: https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/

Hope this helps get you on your way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.