So I am running Jenkins in a docker image on mac with the following command:
docker run -p 8080:8080 -p 50000:50000 --name jenkins -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts-jdk11
So I can access from my local machine using localhost:8080, but from Jenkins I need to configure a plugin that requires to access an app on my local machine, but no idea how I can do that, so I was reading that I should use --network=host but with that I can't access localhost:8080 anymore.
Any idea what I am missing, I need to be able to connect Jenkins with an app on localhost and be able to access Jenkins as well.
Related
I have a Python application to expose a REST API. The Python server is running on http://127.0.0.1:5000
I have another application written in NodeJS to wrap the API coming from Python and expose another API as a passthrough. The Node server is running on http://localhost:8080
I'm new to Docker, I'm building a docker image for the Node application (in MacOS Silicon). The problem is when I invoke the API using curl http://localhost:8080 The docker desktop says "Connection refused: /127.0.0.1:5000"
The following is the docker run command I'm using
docker run --platform linux/amd64 -d -v ./Config.toml -p 8080:8080 myApp/app:v0.1.0
I tried with the --network host flag with the docker run command, but it doesn't work since it ignores all the declared ports. And I tried with the http.server --bind 0.0.0.0 with the docker run command, but the result says "pull access denied for http.server"
How can I solve this?
curl http://127.0.0.1:5000 on host machine to see if server is actually running.
Check server accessibility from within container. Simply run the docker container on interactive it and try access the server from the container.
docker run --platform linux/amd64 -it myApp/app:v0.1.0 /bin/bash
curl http://127.0.0.1:5000
If this does not work, it's a network configuration issue in the container you should set up to allow access to host machine.
If it works, then bind NodeJs app to 0.0.0.0 to allow conns from any ip.
docker run --platform linux/amd64 -d -v ./Config.toml -p 8080:8080 myApp/app:v0.1.0 -host 0.0.0.0
On my Redhat7linux docker host, i have created a jenkins container by pulling the jenkins official image from docker hub and i was able to bring the jenkins container up & running by executing the command:
docker run -d -p 50000:8080 -v $PWD/jenkins:/var/lib/jenkins -t jenkins_master
and i could see the jenkins is up when i checked the logs using the docker logs {containerID} but when i try to launch it in web browser with {hostip}:50000, I couldn't access it as it throws "The site cant be reached", and since my container is running inside a company network, should I either open/enable that port 50000 or do I need to set any proxy in the docker host?
Am I missing something here?
Here are the outputs of the docker command:
The official image provide the following command :
docker run -p 8080:8080 -p 50000:50000 -v /your/home:/var/jenkins_home jenkins
It seems that both ports 8080 and 50000 have to be exposed.
Execute the docker run command to run the container, check the status of your container.
docker container run -p [YOUR PORT]:8080 -v [YOUR
VOLUME]:/var/jenkins_home
--name jenkins-local jenkins/jenkins:lts
you can then access it using localhost:[YOUR PORT]
I pulled jenkins image from docker hub and try to run with the following command:
docker run jenkins
or
docker run -p 8080:8080 -p 50000:50000 jenkins
Then I'm inspecting running jenkins: docker inspect [container id], networks node in output says that ip address is 172.17.0.2 but when I type in browser 172.17.0.2:8080 it can't be reached..
Any ideas?
Please use localhost:8080 or your mac-machine-IP-address:8080 from the browser.
The 172.17.0.2 is docker machine IP address which is not accessible from outside.
Please let me know if it's still not working.
Thanks.
On my host machine, I have installed docker. Then I pull a Jenkins image.
I want to run that image like daemon service like some services runs on my host machine after rebooting my machine every time. And how can I fix Jenkins port permanent(like 8080) in mine docker?
docker run -d --restart always -p 8080:8080 -p 50000:50000 -v /your/home:/var/jenkins_home jenkins
-d: for running the container in background
--restart always: for the container to always restart (unless manually stopped), it will start automatically at boot.
The rest of the arguments are from the jenkins image documentation, you may need to adapt your port mapping and volume path.
I am running the cloudera docker quickstart image (on windows) as explained on the this page.
I run it using:
docker run --hostname=quickstart.cloudera --privileged=true -t -i -p 7180:7180 -p 9080:9080 cloudera/quickstart:latest
It runs fine, I am able to run cloudera manager and access it using the url http://192.168.99.100:7180. So far so good. I also use tomcat with a simple app on localhost:9080 inside this same container. How do I access it on my host? I tried using http://192.168.99.100:9080 but it does not work.
Update: I fixed it by using the vm ip i.e. 192.168.99.100 instead of localhost for the server. Now it works. Thanks.