Unable to access Container url in Bluemix for Spring Boot Application - docker

I am using Toolchain in IBM Bluemix for deploying an Simple Spring boot application.
In Delivery pipeline I have added 3 stages:
Stage-1(Maven Build)
Fetching source code from git repo and building with Maven to build jar file
Stage-2(Building Docker Image)
In this stage it is reading from a Dockerfile in source code and building a Docker image. In this stage Builder Type is "IBM Container Service".
Stage-3(Container Deploy)
In this stage I am deploying the image in Container in Bluemix. Here Deployer Type is "IBM Container Service".
After all stages are completed successfully I hit the container ip provided in deploy stage but it gives an error
A communication error occurred: "Connection refused"
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
I have checked the container status with bx ic inspect some-container-name
it shows container status running.
Any help will be appreciated.

This sounds like a problem with the application. You can investigate by either doing bx ic logs some-container-name or by connecting to the running container by doing bx ic exec -it some-container-name /bin/bash
Edit: You should also make sure you are specifying the correct port in the Container Deploy stage and when trying to connect to the IP address.

Related

Jenkins build Docker container on remote host with dockerfile

I'm quite new to Jenkins and spent 2 whole days not twisting my head (and google and stackoverflow) around, how to get a docker container built on a remote host (from Jenkins host perspective).
My setup:
Docker runs on a MacOS machine (aka the "remote host")
Jenkins runs as docker container on this machine
Bitbucket Cloud runs at Atlassian
PyCharm is my development tool - running on the MacOS machine
Everything works fine so far. Now, I want Jenkins to build a docker container (on the "remote host") containing my python demo.
I'm using a dockerfile in my project:
FROM python:3
WORKDIR /usr/src/app
COPY . .
CMD ["test.py"]
ENTRYPOINT ["python3"]
I'm trying to build a jenkinsfile, I'm expecting to do 2 things
Pull the repo
Build the docker image with the help of the dockerfile on the "remote host"
Docker is installed as plugin and configured.
Docker is installed via Jenkins configuration.
Docker remote host is set up in "Cloud" setup in Jenkins - connection works (with the help of socat running as docker container)
Docker Host ist set to the remote host IP and port 2376
I'm using a jenkins pipeline project.
Most promising threat about using remote hosts is of course https://www.jenkins.io/doc/book/pipeline/docker/#using-a-remote-docker-server
But using docker.withServer('tcp://192.168.178.26:2376') (in my case, locally, no credentials because not reachable from outside), I had no luck at all.
Most common error message: hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.docker.workflow.Docker.withServer() is applicable for argument types: (java.lang.String, java.lang.String) values: [tcp://192.168.178.26:2376]
If I try to let Jenkins build it inside it's own container with its own docker, it tells me /var/jenkins_home/workspace/dockerbuild#tmp/durable-6e12255b/script.sh: 1: /var/jenkins_home/workspace/dockerbuild#tmp/durable-6e12255b/script.sh: docker: not found
Strange, as I thought, docker was installed. But I want to build at remote host anyway.
In my eyes the most promising jenkinsfile is the following - but to be honest, I am totally lost at the moment and really need some help:
node {
checkout scm
docker.withServer('tcp://192.168.178.26:2376')
def customImage = docker.build("my-image:${env.BUILD_ID}")
customImage.inside {
sh 'make test'
}
I appreciate any hint and am greatful for your help.
Best regards
Muhackl

docker is unable to pull the base image | Get https://registry-1.docker.io/v2/:

I am trying to build a docker image using my build pipeline, however docker is unable to pull the base image
my build pipeline is hosted in azure devops server
Azure devops server hosted inside window server 2019 VM
2021-03-04T06:58:21.6816037Z ==============================================================================
2021-03-04T06:58:21.6816138Z Task : Docker
2021-03-04T06:58:21.6816209Z Description : Build, tag, push, or run Docker images, or run a Docker command. Task can be used with Docker or Azure Container registry.
2021-03-04T06:58:21.6816271Z Version : 0.3.24
2021-03-04T06:58:21.6816322Z Author : Microsoft Corporation
2021-03-04T06:58:21.6816387Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=848006)
2021-03-04T06:58:21.6816465Z ==============================================================================
2021-03-04T06:58:22.7477068Z [command]"C:\Program Files\Docker\docker.exe" build -f C:\myagent_agent\_work\7\s\hello-solution\core\Infrastructure\Docker\build\5910\Dockerfile -t myregistry.azurecr.io/myapp-hello:276 C:\heisoul2_agent\_work\7\s\hello-solution\core\Infrastructure\Docker\build\5910
2021-03-04T06:58:26.3591773Z Sending build context to Docker daemon 154.9MB
2021-03-04T06:58:26.3592364Z
2021-03-04T06:58:26.3701800Z Step 1/19 : FROM tomcat:9.0.41-jdk15-openjdk-slim-buster
2021-03-04T06:58:41.7345125Z Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2021-03-04T06:58:41.7599411Z ##[error]C:\Program Files\Docker\docker.exe failed with return code: 1
2021-03-04T06:58:41.7613038Z ##[section]Finishing: Build an image
Docker Desktop window pan not showing options in resources sections
This error encountered due to the destination unreachability problem. It means that the port might be filtered by the local or external firewall, the DNS setting of the machine might be the trouble.
however in my docker desktop window pan, i am not able to see the
option of network that very weird
For this issue, the Network tab is not available in Windows container mode because networking is managed by Windows. This is stated in this official document.
Regarding changing Windows DNS addresses, detailed instructions on how to do so here (see section II).
This document is about configuring container DNS, the information in this section explains configuring container DNS within the Docker default bridge.
Here are some tickets(ticket1, ticket2) with the same issue you can refer to.
I used buildArguments in dockertask in azure-pipeline.yml
buildArguments: 'http_proxy=http://username:password#proxy:80'

Local Gitlab cicd failed 'fatal: unable to access...Could not resolve host:...' with linux runner

I am trying to test my python project and run via gitlab. I have installed runner on my ubuntu notebook and complete registered with local
gitlab server.
Thus, got 2 seperate machine one runner and another one is gitlab server. Both machine can communicate each other.
Notebook(192.168.100.10) ---- GitLab(172.16.10.100)
Once I commit test, my job failed with message below;
Reinitialized existing Git repository in /builds/dz/mytest/.git/
fatal: unable to access 'http://gitlab.lab01.ng/dz/mytest.git/': Could not resolve host: gitlab.lab01.ng
Uploading artifacts for failed job
ERROR: Job failed: exit code 1
From my notebook cli, i can ping gitlab server ip but not the host name even curl also doesnt know the hostname.
I believe this is something to do with the dns that cannot resolved.
I add hostname in my notebook /etc/hosts , i can ping hostname but still failed run job with the same message.
I have tried people suggest add below inside gitlab-runner config.toml, thus I add below in config.toml (Not sure if this is correct to add in config.toml)
[[runners]]
dns_search = [""]
Still failed and got the same message could not resilve host.
What can I do on my notebook setting/runner? I dont have admin access to gitlab to check further.
Anyone face the same problem. Appreciate help and support thank you.
--For information I have tried testing the runner on my notebook with public gitlab (gitlab.com) and I can run the job successfully without any error message--
I'm assuming you are using docker as the executor for your GitLab runner since you did not specify it in your question. Docker executor does not share the /etc/hosts of the host machine but you can use extra_hosts parameter inside your config.toml to let the runner container know about the custom hostname:
[runners.docker]
extra_hosts = ["gitlab.lab01.ng:172.16.10.100"]

Why doesn't TeamCity recognize docker server properties with the jetbrains/agent image?

I have an ECS Fargate service running the jetbrains/teamcity-agent image. This is connected to my TeamCity Host which is running on an EC2 instance(windows).
When I check whether the agent is capable of running docker commands, it shows the following errors:
Unmet requirements:
docker.server.osType contains linux
docker.server.version exists
Under Agent Parameters -> Configuration Parameters, I can see the docker version and the dockerCompose.version properly. Is there a setting that I am missing?
If you are trying to access a docker socket in fargate, Fargate does not support running docker commands, there is a proposed ticket for this feature.
the issue with "docker.server.osType" not showing up usually means
that the docker command run from the agent cannot connect with the
docker daemon running. This is usually due to a lack of permissions,
as docker by default only allows connections from root and users of
the group docker
Teamcity-Unmet-requirements-docker-server-osType-contains-linux
I was facing similar issues got them fixed by adding "build agent" user in "docker" group and restarted/rebooted the server.
Where build agent user ==> Means the user with which your TeamCity services are running.
Command to add a user to group
#chmod -a -G docker <userasperyourrequirement>
Command to reboot the server:
#init 6

pending jenkins doesn't have label docker-slave

I am trying to configure jenkins slave as docker container, have enabled docker API and connections works fine to the API
Have added the configuration for docker template and docker cloud but it seems that my job does not starts
I can see container getting created on my docker node but the job does not start
Docker cloud configuration image
docker template image
One thing to note is that when i run the container specifically on the docker node and then try to ssh using the same credentials that i am using in jenkins i can ssh into the container.
This message of "Jenkins doesn't have label XXXX" is rather misleading and unhelpful.
You think the problem is something you did wrong in your configuration and when you find out what happen it is nothing to do with jenkins or how you set up the docker plugin.
I run into the same problem than you, and the problem was the docker installation I was using.
The steps I followed to fix it were:
(I was using CENTOS7,jenkins 2.1.38, docker version 1.13.1)
1) Go to the logs of your jenkins (centos logs are /var/log/jenkins.log)
2) Looking into the logs you are going to find out the problem. For instance for me was this:
com.github.dockerjava.api.exception.NotFoundException: {"message":"driver failed programming external connectivity on endpoint happy_heyrovsky (cbfa0d43f8c89d2531323249468503be11e9dd603597a870530d28540c662695): exec: \"docker-proxy\": executable file not found in $PATH"}
As you see the problem is that docker it is not able to find docker-proxy ¿how to fix this?
Go to /usr/libexec/docker and you will see docker-proxy-current. so what you have to do is create a link:
sudo ln -s docker-proxy-current docker-proxy
Tha´s all. After doing this change I execute my build on jenkins and it works.

Resources