Bamboo: docker task "An error occurred trying to connect: Post http://127.0.0.1:2375/v1.22/build" - docker

I've been trying to set up an Continuous Delivery server with Bamboo. I've got everything going nicely up to the deployment. Bamboo builds and tests my C# project as it should.
Then I created a "deployment plan", installed docker and added the server capability to use docker, set up the docker tasks to build and deploy to dockerHub.
When I try to deploy, I get this error:
An error occurred trying to connect: Post http: //127.0.0.1:2375/v1.22/build ?buildargs=%7B%7D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&forcerm=1&memory=0&memswap=0&rm=1&shmsize=0&t=srgskiri%2Fresttest&ulimits=null : dial tcp 127.0.0.1:2375: connectex: No connection could be made because the target machine actively refused it.
01-mrt-2016 13:19:03 Failing task since return code of [C:\Program Files\Docker Toolbox\docker.exe build --force-rm=true --tag="srgskiri/resttest" C:\Users\Srg\bamboo-home\xml-data\build-dir\2129921-2195457] was 1 while expected 0
Now I think that it means that the bamboo 'object' that is calling the command to build, can't communicate with my docker engine/container.
First I thought it was because I didn't have docker-machine running, so I started it and ran the deploy, and still got this error.
This is what I have:
Server capability: path to docker
Docker task: building into an Image
Is there something I'm missing?
PS: Docker works perfectly on its own, both with docker UI or docker terminal. It's bamboo that can't interact with docker.
UPDATE: I didn't mention this, but I ran Bamboo in a Console, not as a service. Maybe thats the problem, that bamboo can't access docker out of console. I can't try this myself now because I can't install bamboo as a service. Keeps hanging if I try to start it as a service.
Will ask the bamboo support about it.

I figured it out... If u work on a Windows, Bamboo has to start the docker-machine itself.
So you have to add Command tasks to:
1) create a docker-machine (if u don't have any yet)
2) start it (if you start docker in bamboo, you can't access it in Windows and vice-versa)
only then you are able to use Docker in Bamboo on Windows.
I feel silly now
-EDIT- To use the Docker tasks after starting the docker-machine, you must also specify the Environment variables for the tasks (like DOCKER_TLS_VERIFY=1)
Otherwise you'll get the error mentioned above.

Related

Testcontainers do not start after replacing Docker Desktop with minikube

I want to make my testcontainers in Java integration tests work with minikube replacing Docker Desktop.
I followed below article to get started:
https://www.atomicjar.com/2021/10/docker-on-windows-and-macos/#minikube
This is what I've got in testcontainers.properties
docker.client.strategy=org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy
docker.host=tcp\://192.168.64.2\:2376
docker.cert.path=/Users/username/.minikube/certs
docker.tls.verify=true
Although my docker is up and running, I'm getting following exception:
Caused by: java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
Can anybody please suggest anything to make it working?
TA
If you are using gradle try -no-daemon flag to use a new daemon. Your old gradle daemon still using your previous testcontainers properties, also restart your IDE if you're running your build inside.
After restarting Minikube and Intellij editor, and updating testcontainer-bom to be the latest - from 1.15 to 1.16.2, I was able to pull some third-party docker images. This means docker is working now.
However, I'm still trying to find a way to work with local images (Other application docker images) for integration testing as it used to work with Docker Desktop.

ERROR: traefik, xdbautomationworker, Container is unhealthy

Trying to create sitecore 10 image using Docker on Windows 10 Enterprise locally but getting unhealthy containers. Please help me out as I have tried various steps that was updated in the forums.
Getting below errors:
Creating network "sitecore-xp0_default" with the default driver
Creating sitecore-xp0_solr_1 ... done
Creating sitecore-xp0_mssql_1 ... done
Creating sitecore-xp0_id_1 ... done
Creating sitecore-xp0_solr-init_1 ... done
Creating sitecore-xp0_xconnect_1 ... done
Creating sitecore-xp0_cm_1 ... done
ERROR: for cortexprocessingworker Container "992574e988e3" is unhealthy.
ERROR: for xdbautomationworker Container "992574e988e3" is unhealthy.
ERROR: for xdbsearchworker Container "992574e988e3" is unhealthy.
ERROR: for traefik Container "933b548fc2f9" is unhealthy.
ERROR: Encountered errors while bringing up the project.
Checked the following things:
docker-compose stop on Powershell.
docker-compose down on Powershell.
iisreset /stop on Powershell to make sure that the required ports are free.
docker-compose up -d on Powershell.
Stopped, removed the container and executed the command docker-compose.exe up --detach multiple times but no luck.
Check the .env file and make sure SITECORE_LICENSE has a value.
You may need to run the init.ps1 file.
Based on the logs now provided in the comments above, my suggestion would be to check the collection SQL connection string, to the shardsmanager database.
You can inspect the SQL container in docker for Windows and find the IP address of the SQL server. Connect to that using ssms and try connecting with the creds you have in current string.
Edit: looking again at the exception, it looks like it can't find the SQL server. Yet the CM server appears to not have a problem finding the same server. So compare the web/master/core connection string to the collection one. I'm guessing the SQL server portion will be different?

Remote debugging of Docker containers using IntelliJ

I have a number of Docker containers (10) each running a Java service that makes up my system. To create these containers I use a couple of docker-compose files. Using the Docker Integration plugin for IntelliJ, I can now spool up these services to my remote server using the Docker-compose option (the images used are built outside of IntelliJ, using Gradle). Here are the steps I have done to achieve this:
I have added a Docker server using the Docker Machine option to connect to the remote Docker daemon (message says Connection Successful).
I have added a new Docker Compose configuration, using the server, specifying my compose files, and the services I want to start.
Now that I have the system controlled through IntelliJ, I have been trying to figure out how to attach the remote debugger to each of these services so that IntelliJ will hit my breakpoints.
Will I need to add the JVM args (-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005) to each service (container) and add the usual remote debug configuration for each service? Do I need to use a different address for each service? If so, how do I add these args? Surely with the Docker Integration plugin, there is an easier way to do this.
IntelliJ Idea v2018.1.5 (Community Edition)
Docker Integration v181.5087.20

PhpStorm: running PHPUnit database tests from Docker container

I configured PhpStorm to run PHPUnit tests from Docker container. Unfortunately if test tries to connect to MySQL server I get an error:
SQLSTATE[HY000] [2002] Connection refused
MySQL server runs in the same container. If I try to connect to MySQL server from container via some standalone script - it works fine.
Also the app itself works fine too.
Other tests (without database usage) work fine.
Any ideas what is wrong with my PhpStorm configuration? I followed official step by step configuration video tutorial, but it does not cover database part.
PhpStorm runs command that is being executed every time I hit run tests button:
docker://mycontainer/myapp:v1.0/php /opt/.phpstorm_helpers/phpunit.php --configuration /var/www/myapp/tests/phpunit.xml /var/www/myapp/tests/unit
Maybe problem is with phpstorm_helpers? Because it stands as separate container. Maybe my app container and helper container should be linked somehow?
What I need is to run tests in existing container which I start only once. Depending on this thread PhpStorm does not have such functionality yet.
So I switched to remote interpreter instead. Now PhpStorm connects to container via SSH. I know, it's a bit gruesome, but for this moment it's what I need.
Still if somebody wants to run integration tests with PhpStorm and Docker in proper way there is a good thread about it.

Can't pull image from private docker registry

Trying to get a private repo running on my EC2 instance so my other docker hosts created by docker-machine can pull from the private repo. I've disabled SSL and have put up a firewall to compensate that allows my test server(the one I'm trying to pull on) to connect to my main EC2 instance (the private repo). So far I can push to the private repo where it's hosted on my main EC2 instance (was getting an EOF error before disabling SSL) but I get the following error when I run this on my text server:
docker pull ec2-xx-xx-xxx-xxx.us-west-2.compute.amazonaws.com:5000/scoredeploy
this is the error it spits out:
Error response from daemon: Get https://ec2-xx-xx-xxx-xxx.us-west-2.compute.amazonaws.com:5000/v1/_ping: EOF
Googling this error on yields results of people having similar issues, but without any fixes.
Anybody have any idea of what's going on here?
You might need to set the --insecure-registry <registry-ip>:5000 flag on the docker daemon's startup command on your non-docker-registry machine. In your case: --insecure-registry ec2-xx-xx-xxx-xxx.us-west-2.compute.amazonaws.com:5000
If you want to use your already-running docker machine, this should help you out setting the flag: https://docs.docker.com/registry/insecure/#/deploying-a-plain-http-registry
If you're using boot2docker, the file location and format is slightly different. Give this a shot if this is the case: http://www.developmentalmadness.com/2016/03/09/docker-configure-insecure-registry-in-boot2docker/
I've had issues with my docker machines not saving this setting on reboots. If you run into that issue, I'd recommend you make a new machine including the flag --engine-insecure-registry <registry-ip>:5000 in the docker-machine create command.
Best of luck!

Resources