isudoajl
Mission Specialist
Mission Specialist
  • 798 Views

How to map a port on RUNNING container using PODMAN?

Jump to solution

Hello!

Somebody can help me on how to do this? The main idea that I have is that I need to stop it first..

The little I have found has been with Docker platform and didtn work with Podman.

Thanks.

Labels (4)
0 Kudos
15 Replies
Rajanikanty
Mission Specialist
Mission Specialist
  • 204 Views
sudo docker ps 
sudo docker commit <containerid> <name/tag>
sudo docker run -i -p 22 -p 8000:80 -m /data:/data -t <name/tag> /bin/bash
0 Kudos
ipalagin
Mission Specialist
Mission Specialist
  • 148 Views

If your container already has SSH running and exposed, you can log into it interactively, reconfigure it to allow port forwarding and access your service through the port 22.

BTW, k8/openshift resolves this challenge by cloning a running container, additional ports can be exposed on the clone.

 

0 Kudos
Trevor
Starfighter Starfighter
Starfighter
  • 138 Views

May I learn what type of container is involved here?

Trevor "Red Hat Evangelist" Chandler
0 Kudos
isudoajl
Mission Specialist
Mission Specialist
  • 131 Views

I appreciate all the answers but I still can't find the solution, I'm not working with Docker, I'm working with Podman, they are very similar but the solution presented to me through Docker does not work for me in podman.

I am working with docker.io/redhat/ubi8-init image...

I did not imagine that it would be so difficult to find a solution to this problem using PODMAN.

0 Kudos
isudoajl
Mission Specialist
Mission Specialist
  • 125 Views

Revisiting one of the previous answers in detail I found a kind of solution, doing a commit:

$ docker stop httpd-container
httpd-container
$ docker commit httpd-container httpd-image
sha256:33da33fcad051c90ac9b7dea9b2dbda442767e05ddebd8d6db8ac6893ef4ef40

Next, we’ll remove the container and start a fresh container using the image that we just created.

 

We need to make sure we add/update the port mappings in the run command this time:

$ docker rm httpd-container
httpd-container
$ docker run -d -p 83:80 --name httpd-container httpd-image
dd2535c477ad74e80b3642abca9055efacb89eaf14572b91f91bf20cd3f0cbf3

This kind of solution works because the main point is not to lose all the setup that has already been made in the container.

If anyone knows of another type of solution that works with PODMAN too, I'd like to know...

0 Kudos
jstanesic
Cadet
Cadet
  • 44 Views

I think your approach might be wrong but your question is valid and I can see you found an answer. You shold not be depending on that that is set up inside the container. If container is not stateless, you should persist data that needs to survive container re creation inside a volume. Container setup should be stored inside Dockerfile used to build it.

0 Kudos
Join the discussion
You must log in to join this conversation.