Jenkins on docker won't run on port 8080 - docker

I have 'docker desktop' installed on my windows 10.
so, I pulled in Jenkins image from docker hub and then run the commands:
docker pull jenkins/jenkins
docker volume create jenkins_home
docker run --name jenkins -p 8080:8000 -p 50000:50000 -v C:/Users/myusername/Documents/jenkins_home:/var/jenkins_home jenkins/jenkins
On console, everything was ok, and get the password for the admin user.
So after that I run
docker start jenkins
and then
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
36683f39dd31 jenkins/jenkins "/sbin/tini -- /usr/…" 6 minutes ago Up 2 minutes 8080/tcp, 0.0.0.0:50000->50000/tcp, 0.0.0.0:8080->8000/tcp jenkins
Now, I need to log into http://localhost:8080/ port to view the Jenkins web app. But did not bring up Jenkins app. I also tried using docker inspect to get the container's ip, but port 8080 didn't work on those ips as well.
"NetworkSettings": {
"Bridge": "",
"SandboxID": "19504b4695ca4dfc9c4af41c9a7ef90115004af07d0099ffed33f4838155cddb",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"50000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "50000"
}
],
"8000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
],
"8080/tcp": null
},
"SandboxKey": "/var/run/docker/netns/19504b4695ca",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "f1938dad37524b58d3146f8bfffa4964687d1946ab97b3ae7f0105ced3f64ddf",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"Aliases": null,
"NetworkID": "b285258a51bc4877fa9ff8a1928eced061f61a4f92f54a5aa756a118e0f1cb7b",
"EndpointID": "f1938dad37524b58d3146f8bfffa4964687d1946ab97b3ae7f0105ced3f64ddf",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
NOTE: Before running jenkins, I made sure the port wasn't busy.
netstat -aon | findstr 8080
After kenkins running, the command shows me
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 25076
TCP [::]:8080 [::]:0 LISTENING 25076
If I find the process to use this port, I got this
tasklist | findstr 25076
com.docker.backend.exe 25076 Console 2 22.664 K
so, Which ip address do I use to see the Jenkins app that is running in the container? and why the localhost on port 8080 doen't work ?

Related

MySQL-workbench and Docker Can't connect to MySQL server on '127.0.0.1' (61)

Om Mac I'm using docker for my local web and I want to access mysql with MySQL-workbench but after I did install MySQL-workbench and try to connect to database I get this error message
Can't connect to MySQL server on '127.0.0.1' (61)
I tried to find solution for docker but I didn't find any.
docker inspect pkbook_mysql_1
"NetworkSettings": {
"Bridge": "",
"SandboxID": "cb984bedd303958298621c1571482c7c06a2a326df021902c15a7955b8c26b2c",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3306/tcp": null
},
"SandboxKey": "/var/run/docker/netns/cb984bedd303",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"publiquip_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"mysql",
"ee6b2dd46fb8"
],
"NetworkID": "8809726a588595aea20989df3608ae6646f2e64aa928974469df34b52febe7a4",
"EndpointID": "f41cf7f7e42f4921393e13c7db9ce046c784c159ad0ff3c74d45ed788323d4b1",
"Gateway": "172.20.0.1",
"IPAddress": "172.20.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:14:00:04",
"DriverOpts": null
}
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e34b4dbad1e3 pkbook_joomla "/entrypoint.sh apac…" 4 days ago Up 5 hours 0.0.0.0:80->80/tcp pkbook_joomla_1
ee6b2dd46fb8 mysql:5.6 "docker-entrypoint.s…" 6 days ago Up 5 hours 3306/tcp pkbook_mysql_1
0ccd811b7955 pkbook_gulp "docker-entrypoint.s…" 6 days ago Up 5 hours pkbook_gulp_1
You need to publish the 3306 port with the -p opt option.
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -p 3306:3306 mysql
Instead of host 127.0.0.1 try to type container name and port.
If it doesn't work.
In terminal type docker ps. (If You didn't gave the name during container creation, docker will name it by random name). If container is running You should see it on the list.
Then check IP and PORT:
docker inspect [CONTAINER-NAME]
and find under:
"NetworkSettings":
"3306/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "33082"
}
],
"33060/tcp": null
},
So, in this situation it's 0.0.0.0:33082
You need to set the allow login from any ip with MYSQL_ROOT_HOST=%
Full docker command line as follows:
>docker run --name mysql-server -e MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql/mysql-server
--name means that it's container name
-d means that it's mysql docker image
When docker status is Up 3 minutes (healthy) you can easy connect to DB via mysql Workbench

Docker-toolbox cannot access VM by IP

I run: docker run -p "9999:80" nginx and attempt to access the web server using the following address: 172.17.0.2:9999. I got this IP from docker inspect [container_id]:
"NetworkSettings": {
"Bridge": "",
"SandboxID": "877eb750a0f35037f0b9dff2b6bd95f7dd4aaf80ae0ed8cf65e20ad8aeb85132",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9999"
}
]
},
"SandboxKey": "/var/run/docker/netns/877eb750a0f3",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "2599dc8c2311725e9816fc30e60a86550cb42887871a921365e3df866427464e",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "ffc037f862047b118824b8d322aab771ba75a009881959461be577ffebb42a80",
"EndpointID": "2599dc8c2311725e9816fc30e60a86550cb42887871a921365e3df866427464e",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
But this doesn't work as expected. If I ping 172.17.0.2 from the host I get no response.
Any ideas what's going wrong? It's so much hassle with docker-toolbox because my version of Windows 10 isn't supported by docker.
Since you launched the container with docker run -p 9999:80, you can reach it on the VM's IP address on the public port 9999. docker-machine ip will tell you that IP address (but it is usually 192.168.99.100). So try http://192.168.99.100:9999/ as a URL to reach the container.
The container-internal IP addresses aren't especially useful. One significant problem with them is that they can't be reached from other hosts. In the case of a Docker Toolbox environment, everything Docker-related actually runs inside a virtual machine, and your host system counts as "other hosts" for this. Also note that if you do have occasion to use it (or more often use inter-container DNS for one container to reach another by its docker run --name) you need the port the server is listening on inside the container, not the published port: from another container you might use http://nginx_container_name:80/.

Docker: Unable to connect to container from host

I try to use docker-compose in order to run an app which consists of 2 container: akka app and postgresql.
Here is yaml file:
version: "3"
services:
api:
image: akka-app:latest
ports:
- "9000:5000"
db:
image: postgres-db:latest
After the docker-compose up command I see that containers are up and running using docker ps command:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
65326e5a9677 akka-app:latest "java -cp /..." 40 minutes ago Up 23 seconds 0.0.0.0:9000->5000/tcp samplecompose_api_1
1f86273c4f9a postgres-db:latest "docker-ent..." 19 hours ago Up 23 seconds 5432/tcp samplecompose_db_1
But when I try to access the akka-app from the host via the GET request to 0.0.0.0:9000/status or localhost:9000/status I get back "refused to connect" error in the postman.
Extra information:
Docker version 17.06.0-ce, build 02c1d87
docker-compose version
1.14.0, build c7bdf9e MacOS Sierra 10.12.5
Network settings of the akka-app container:
"NetworkSettings": {
"Bridge": "",
"SandboxID": "5b5b322ffb0fb881317f8cb4e69b8fd887566b8c5b73940174aabace35d816f8",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"5000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9000"
}
]
},
"SandboxKey": "/var/run/docker/netns/5b5b322ffb0f",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"pinpointcompose_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"api",
"65326e5a9677"
],
"NetworkID": "925c8379c6d5b334177d7d198d1d38e29983903474183bee5734df9d30ab9810",
"EndpointID": "c7c37f545b00c6a19863315858e93a79f10b54b5675dc2cb8704d2f2f9b2bb1c",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02"
}
}
}
UPDATE:
docker-compose output:
docker-compose up
Starting samplecompose_api_1 ...
Starting samplecompose_api_1
Starting samplecompose_db_1 ...
Starting samplecompose_api_1 ... done
Attaching to samplecompose_db_1, samplecompose_api_1
db_1 | LOG: database system was shut down at 2017-07-06 08:54:56 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
api_1 | 09:04:26.030 [default-akka.actor.default-dispatcher-3] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
api_1 | 09:04:27.472 [default-akka.actor.default-dispatcher-4] INFO sample-service - Bound to /0.0.0.0:5000
The problem was in an old VirtualBox installed who knows when on my laptop. So while it was installed I could not access running docker containers via localhost...
You can read more about this on official docker site
After I uninstalled the VirtualBox from the laptop, then restarted the Docker app and relaunched the terminal sessions it was unreal to use localhost for access to the containers.
Instead of the localhost I used the IP which I got from the docker-machine ip default. But this is not the good way.
So ensure once again that you meet all of the requirements.

Docker: can not access container host/port

I have a container
ps -a
de3ff650fbef tasklist-img "/bin/sh -c 'java -ja" 2 minutes ago Up 2 minutes 8080/tcp, 0.0.0.0:8080->8081/tcp tasklist-img-01
And could not access like localhost:8080/task-list
When I inspect I got json with ip address 172.17.0.2, it is also unreachable
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "82398f58a56f6685223df13f0e053c1ad388505ff595ec270eb4e9a445109641",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8080/tcp": null,
"8081/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"SandboxKey": "/var/run/docker/netns/82398f58a56f",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "e8d9d3e209e858d6e881295899949df457fd8ca28cb059105bebceb6015e1e7d",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "24ef0b8e2aea470b5a0c4e48b96e5b203ea35b291689fe6d73b71b870c86f659",
"EndpointID": "e8d9d3e209e858d6e881295899949df457fd8ca28cb059105bebceb6015e1e7d",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
My docker machine run under ip 192.168.99.100
i run container with command
docker run -d -p 8080:8081 --name tasklist-img-01 tasklist-img
I can access http://192.168.99.100:8080/ and it is return only dropwizard metrics, http://192.168.99.100:8080/task-list/ unreachable
I have also log
INFO [2016-11-14 19:32:29,324] io.dropwizard.server.DefaultServerFactory: Registering admin handler with root path prefix: /
INFO [2016-11-14 19:32:29,402] org.eclipse.jetty.setuid.SetUIDListener: Opened application#522a32b1{HTTP/1.1}{0.0.0.0:8080}
INFO [2016-11-14 19:32:29,402] org.eclipse.jetty.setuid.SetUIDListener: Opened admin#35390ee3{HTTP/1.1}{0.0.0.0:8081}
INFO [2016-11-14 19:32:29,406] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT
INFO [2016-11-14 19:32:30,428] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
GET /task-list (com.bjedrzejewski.tasklistservice.TaskListResource)
GET /task-list/big (com.bjedrzejewski.tasklistservice.TaskListResource)
INFO [2016-11-14 19:32:30,435] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler#378bd86d{/,null,AVAILABLE}
INFO [2016-11-14 19:32:30,450] io.dropwizard.setup.AdminEnvironment: tasks =
POST /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask)
POST /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask)
WARN [2016-11-14 19:32:30,451] io.dropwizard.setup.AdminEnvironment:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW !
! IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE !
! LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR !
! APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT. !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
INFO [2016-11-14 19:32:30,456] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler#7b60c3e{/,null,AVAILABLE}
INFO [2016-11-14 19:32:30,486] org.eclipse.jetty.server.ServerConnector: Started application#522a32b1{HTTP/1.1}{0.0.0.0:8080}
INFO [2016-11-14 19:32:30,487] org.eclipse.jetty.server.ServerConnector: Started admin#35390ee3{HTTP/1.1}{0.0.0.0:8081}
So I cant understand where is my micro service?:)))
Looks like you mapped port 8081 of the container to 8080 of the host
docker run -d -p 8080:8081
And there are ports listening on 8080 and 8081
INFO [2016-11-14 19:32:30,486] org.eclipse.jetty.server.ServerConnector: Started application#522a32b1{HTTP/1.1}{0.0.0.0:8080}
INFO [2016-11-14 19:32:30,487] org.eclipse.jetty.server.ServerConnector: Started admin#35390ee3{HTTP/1.1}{0.0.0.0:8081}
You can access it, sure, but this is not the true 8080 of the container.
You probably need to publish the range of ports
docker run -d -p 8080-8081:8080-8081

Run netflixoss Docker on Windows 8.1

I have installed docker-toolbox v1.12 locally on a Windows 8.1 laptop.
As suggested here I have run docker run -d --name exhibitor netflixoss/exhibitor:1.5.2. This has pulled all the images in my Docker VM "home". docker inspect <<container-id>> (container id obtained from docker ps command) reveals my Network Settings as below.
"NetworkSettings": {
"Bridge": "",
"SandboxID": "c1a16c1704f76b2e2a35b2ae6a18780aaedac078cceb005b419cafb405b1e3b2",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"2181/tcp": null,
"2888/tcp": null,
"3888/tcp": null,
"8080/tcp": null
},
"SandboxKey": "/var/run/docker/netns/c1a16c1704f7",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "3e19d6c6eeb2e7c9dbb9b357ac4ecc9515bdf391df6688f17420bb9443ce3d22",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "85b5af82cb891978b6d3272f622c747fa68546d0401a24e85c9d42f7644ea2d4",
"EndpointID": "3e19d6c6eeb2e7c9dbb9b357ac4ecc9515bdf391df6688f17420bb9443ce3d22",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
}
I'm trying to invoke the running Docker container from Windows host using "http://172.17.0.2:8080/exhibitor/v1/ui/index.html". But that doesn't seem to work. docker ps suggests the container is up
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
1a849df14320 netflixoss/exhibitor:1.5.2 "java -jar exhibitor-" About an hour ago Up About an hour 2181/tcp, 2888/tcp, 3888/tcp, 8080/t
cp exhibitor
Also I can connect to the container using docker attach 1a849df14320 and see the following log entries time-to-time
INFO com.netflix.exhibitor.core.activity.ActivityLog Cleanup task completed [pool-2-thread-93]
I'm a complete newbie with Docker.
You have not exposed the port to the host.
docker ps -a should give output similar to:
0.0.0.0:1234->9876/tcp, 0.0.0.0:4321->7890/tcp
This shows port 1234 on the host is mapped to 9876 in the container.
Your docker ps output has no port mappings. You should do:
docker run .......... -p 8080:8080
You can always use the -P flag too (if you expose the port in the Dockerfile) but the above solution is the quickest.

Resources