Search code examples
dockercontinuous-integrationsonarqubedocker-machineportainer

Docker container port conflict Portainer/Sonarqube


I'm using portainer, and I'm using jenkins for continuous integration. It's all working fine. But now I'm trying to use Sonarqube with jenkins, but portainer and sonarqube have a default port 9000, and only the first container running works, to work one I have to stop the other container.

I've tried to build the container with a different port, but it always put automatically the 9000 port as well.

Anyone know how can I change this default port? How can I solve this port conflict? I'd like to use sonarqube in a different port.

docker run -d --name sonarqube -p 7000:7000 sonarqube

I'm using CentOS, and when I run this command the container stay with port 7000/tcp and 9000/tcp. And the same happens if I try to change portainer's container port to other number.


Solution

  • Please provide your docker-compose.yml or docker command. Basically you can map to another port using -p <host_port>:<container_port> as argument in docker run command or inside the service definition of docker-compose.yml.

    docker run -p 9999:9000 // you can access from host on port 9999