I have the next setup:
When I am starting the container (in a pipeline script) I am trying to add also the host network and also binding ports.
node {
docker.image('localhost:5000/build_deploy_agent:base').withRun('-t --network host -p 9101:9101') { c ->
sh 'doing stuff'
}
}
I need this because at the end I want to keep the container alive with the deployed application.
The problem is, no network or ports are assigned to the container. Only the -t command is taken in consideration.
Is there a way to do this or I am losing time?
Check first if the network is visible through inspection, instead of just docker ps
.
See "How to find the network my container is in?"
docker inspect <lyContainer> -f "{{json .NetworkSettings.Networks }}"
Or you could filter docker ps by network, again, to check if the containers were assigned to the expected network.
You can also check your network stack through a Jenkins step like ip addr show
to see if a new network interface was created.