Unable to connect to local Docker host from Jenkins - docker

I have docker installed on my Windows 10 OS on my laptop. Also I have pulled the jenkins image and created a container out of it (Image: docker pull jenkins/jenkins:latest).
My jenkins is up and running on localhost:8080. Now I have installed Docker plugin within the Jenkins and then I Add a new Cloud to run my build against docker.
However, while giving the docker host URI as "tcp://localhost:2375" it is giving me Connection Refused
Debug Steps:
I have already made by docker server listening on port 2375
I tried adding the host entry in C:\ProgramFiles\Docker\config\daemon.json
I tried adding an env variable DOCKER_HOST to "tcp://localhost:2375
But none of the above worked.
However, when I launch jenkins on my local windows machine instead of launching it from docker, it is able to resolve the Docker host URI.

Related

Docker remote container build over ssh

I want to run every docker command on the remote host. I've set environment variable DOCKER_HOST to ssh://root#192.168.4.228
This works correctly. But every command asks for the password. Is there any way to use a ssh-key?
OS: Windows 2019 Server.
Docker: 20+.

Is there any configuration to run docker inside a jenkins container?

I am trying to build an image with docker and then upload it to the docker hub, after passing the quality tests I receive the following error: docker: not found, how can I communicate my docker service (localhost) with the container of jenkins.
Important: I have docker desktop installed locally and I have installed jenkins in a local container also in windows 10 pro.
Error: https://imgur.com/q1SrKGe
Pipeline: https://imgur.com/nQWL1HR
You have 2 options to do this:
Install Docker inside your Jenkins Container and also add a bind mount for the Docker socket from your host. Otherwise your Docker Daemon inside your Container wont work. On Linux this socket is /var/run/docker.sock, so the bind mount would look like -v /var/run/docker.sock:/var/run/docker.sock.
Use a different slave agent for the Building Image Stage where you have docker installed. For e.g. you could use Docker-in-Docker (https://hub.docker.com/_/docker) as a Slave Agent for Jenkins (connected via ssh) and run your docker build inside this slave agent.

Unable to access Jenkins container outside of host network

I am stuck in a step. I am using an ubuntu vm which is in Azure cloud through terminal; don't have UI access. There I have installed docker and pulled the jenkins image. I have mapped this container from my host machine by running following command - docker run -p 8080:8080 jenkins to access this jenkins from my MAC using Ubuntu IP address:8080, however I am getting the This site cannot be reached. So do I am following or missed any steps to mapped the container outside of docker host machine? Please help!

Mount a local folder into docker container running in a VM

I have the following scenario:
Docker CLI is running on my machine.
There is a remote VM running the docker demon inside. The API is exposed. My local Docker CLI connects to the docker demon inside the VM.
I have my project folder on my local machine. When I run a docker build, the files from my local folder are correctly sent to the docker demon in the VM and used to build an image.
However, when I run the image, I also want to mount my local project folder into the docker container running in the VM so I can make changes and see the results. This seems to be impossible - I seem to be only able to mount folders from my VM into the docker image.

No connectivity between EC2 instance and Docker container

I have an EC2 instance (Ubuntu 16.04 ami-ba602bc2) deployed. I've installed docker on it and downloaded a Docker container that runs JasperReports in Tomcat. I've tested this Docker container on my laptop and it works correctly. I downloaded and started the Docker container on the EC2 instance with
docker run -itd -p 8080:8080 dwschulze/jasperreports.server.v7.1.ubuntu.16.04:latest
the same command I use locally to run on my laptop. docker ps shows the container running. I've opened port 8080 in the AWS security group.
I've also connected to the Docker container and verified that the tomcat instance is running.
I can't connect to the reports server from the internet. I've also tried telnet localhost 8080 from the EC2 instance and it times out.
Everything I've read says that I should be able to run a Docker container on an EC2 instance, but it can't even connect locally.
Any ideas?
Thanks.
My problem was that I was running in a t2.small which is too small to even run Tomcat (let alone Jasper Reports) reliably. I switched to a t2.xlarge and problem solved.

Resources