19 June 2016

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:
  jenkins:
    image: jenkins:latest
    ports:
      - "8080:8008"
      - "50000:50000"
    volumes:
      - /home/arvin/jenkins:/var/jenkins_home jenkins
Artifactory via  docker run:
$ docker run -d --name myartifact -p 8081:8081 docker.bintray.io/jfrog/artifactory-oss:latest
Artifactory via docker-compose:
 artifactory:
    image: docker.bintray.io/jfrog/artifactory-oss:latest
    ports:
      - "8081:8001"
    volumes:
      - /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.

Resolution:

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
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

172.17.0.3 b92facb1d664

Eventually I was able to authenticate the jenkins plugin with artifactory's container IP as follow:
URL: http://172.17.0.3:8081/artifactory




2 comments: