I was working with containers recently with Jenkins. I didn’t want the server process running on my machine all the time, but I did need to allow some communication. Jenkins uses 8080 by default, but agents need another port.
I figured there was a way to do this, and I found it on Stack Overflow, which is the perfect forum for a question like this. The answer? Multiple –p parameters.
Instead of
docker run –-name jenkinsci –p 8080:8080 jenkins/blueo
I do this:
docker run –-name jenkinsci –p 8080:8080 -p 50000:50000 jenkins/blueo
That opens two ports from the host to the container, which is what I need.