3

I created a pod named multi-container. Its a yaml file:

apiVersion: v1
kind: Pod
metadata:
  name: multi-container
spec:
  containers:
  - image: nginx
    name: nginx-container
  - image: redis
    name: redis-container
  - image: consul
    name: consul-container

If I need to login to any of the container, what command do I use?

Artur Meinild
  • 31,035

2 Answers2

7

I'm not an expert on Podman, but as far as I can see from the documentation, the commands are the same as in Docker (since Podman is intended as a daemonless drop-in replacement for Docker).

The basic syntax for running a command inside a container is:

podman exec [options] [container-name] [command [args …]]

So if you want to run an interactive shell (login) in the nginx-container, you would use:

podman exec -ti nginx-container /bin/sh

Or a bash shell: (depends on the container if this exist)

podman exec -ti nginx-container /bin/bash

The -ti option attached a virtual console and starts an interactive session.

Artur Meinild
  • 31,035
1

The yaml looks like a part of an POD Specification for Kubernetes / Openshift / Minikube etc.

It can be deployed with

kubectl apply -f <FILENAME>

and generates a single POD with 3 Container. for Login use the kubectl syntax

kubectl exec -it <PODNAME> -c <CONTAINERNAME> -- /bin/sh

PODNAME and CONTAINERNAME must be replaced with your Values.

This would look like

kubectl exec -it multi-container -c consul-container -- /bin/sh

If you use openshift you man use oc instead on kubectl.

kubectl is very well documented. see Kubectl documentation

dummyuser
  • 1,088