Jenkins Docker Container Problem Connecting to JFrog Artifactory Docker Container

So I was setting up Jenkins in Docker to build Gradle projects and push the WAR artifacts to JFrog Artifactory Docker container.

I have started the Jenkins and Artifactory containers as follows:

Jenkins via  docker run:
$ docker run --name myjenkins -p 8080:8080 -p 50000:50000 -v /home/arvin/jenkins:/var/jenkins_home jenkins
Jenkins via  docker-compose:
    image: jenkins:latest
      - "8080:8008"
      - "50000:50000"
      - /home/arvin/jenkins:/var/jenkins_home jenkins
Artifactory via  docker run:
$ docker run -d --name myartifact -p 8081:8081
Artifactory via docker-compose:
      - "8081:8001"
      - /home/arvin/artifact/data:/var/opt/jfrog/artifactory/data
      - /home/arvin/artifact/logs:/var/opt/jfrog/artifactory/logs
      - /home/arvin/artifact/etc:/var/opt/jfrog/artifactory/etc

Artifactory plugin for jenkins has been installed. In the main jenkins configuration, when try to configure Artifactory server with following settings I get the error:
URL: http://localhost:8081/artifactory
Default Deployer Credentials
Username: admin
Password: password

"Error occurred while requesting version information: Connection refused (Connection refused)"

Even though default artifactory credentails admin/password was correct.


After much hassle, it turns out for some unknown reasons, jenkins artifactory plugin couldn't resolve http://localhost:8081/artifactory even though the docker mappings was correct and was possible to connect to artifactory web based console with the same URL.

Replacing "localhost" with docker container IP solved did the trick.
$ docker inspect myartifactoryID
or simply login to the running container and read hosts file:
$ docker exec -it myartifactory cat /etc/hosts localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters b92facb1d664

Eventually I was able to authenticate the jenkins plugin with artifactory's container IP as follow:


Post a Comment

Popular posts from this blog

Linux and AIX user non expiry and force password change at first login

Rebuild your new Yum repository after changing the packages

Running Docker Wildfly/JBoss Application Server in Debug mode via Eclipse