Score:0

Which command do I use to login to a container with podman?

mf flag

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 avatar
vn flag
Is this for Podman?
santhosh avatar
mf flag
In the pod, I had created 3 container. Now if i need to login to any of the container. what command i need to give.
dummyuser avatar
uy flag
Hi @santhosh This yaml looks much more like a POD specification for Kobernetes than for docker / podman. Please clarify your environment.
Artur Meinild avatar
vn flag
Yes please specify if this is a Kubernetes cluster.
Score:1
vn flag

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.

Score:1
uy flag

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

Artur Meinild avatar
vn flag
You're probably right - but since the OP is not specifying what it is, it's hard to know unless you're very familiar with the syntax.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.