I am setting up a CI/CD pipeline on a Windows 10 machine using Jenkins to build a Docker image and then push it to a Nexus repository. All these services are containerized and orchestrated via Docker Compose, and I’m using Docker Desktop for managing the containers. However, during the “Push to Nexus” stage in Jenkins, I encounter an error suggesting Docker is attempting to communicate over HTTPS instead of HTTP, despite my configurations.
The error log from Jenkins is as follows:
Shell Script -- echo 'admin123' | docker login -u admin --password-stdin http://nexus:8082/repository/calculator-docker-repo/ (self time 407ms)
+ echo admin123
+ docker login -u admin --password-stdin http://nexus:8082/repository/calculator-docker-repo/
Error response from daemon: Get "https://nexus:8082/v2/": http: server gave HTTP response to HTTPS client
The relevant part of my Jenkinsfile looks like this:
stage('Push to Nexus') {
steps {
script {
def nexusCreds = withCredentials([usernamePassword(credentialsId: 'Nexus_Admin_Credentials', usernameVariable: 'NEXUS_USERNAME', passwordVariable: 'NEXUS_PASSWORD')]) {
return [username: NEXUS_USERNAME, password: NEXUS_PASSWORD]
}
sh "echo '${nexusCreds.password}' | docker login -u ${nexusCreds.username} --password-stdin http://nexus:8082/repository/calculator-docker-repo/"
sh 'docker tag calculator_image:latest http://nexus:8082/repository/calculator-docker-repo:latest'
sh 'docker push http://nexus:8082/repository/calculator-docker-repo:latest'
}
}
}
I’ve configured the Docker daemon to allow insecure registries and set up the Nexus repository to use an HTTP connector on port 8082. I expected Docker to communicate over HTTP and successfully login to the Nexus repository.
daemon.json configuration:
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"insecure-registries": [
"http://nexus:8082"
]
}
docker-compose.yml configuration for jenkins-docker service:
jenkins-docker:
environment:
- DOCKER_INSECURE_REGISTRY="nexus:8082"
Nexus Repository Settings:
- Name: calculator-docker-repo
- Format: docker
- Type: hosted
- URL: http://localhost:8081/repository/calculator-docker-repo/
- HTTP Connector Port: 8082
- HTTPS Connector: No
Despite these configurations, Docker is still attempting to communicate over HTTPS. I’ve restarted Docker Desktop, reviewed all configurations, and even tried specifying the http:// scheme explicitly in the Jenkinsfile commands, but the error persists.