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.
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.
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...
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.