Docker container not running over browser - spring

I have containerized my application locally through docker. It is a spring mvc app and it starts successfully
Web application available (default_host): http://479c9c236b5f:9080/ibm/saml20/
[AUDIT ] CWWKT0016I: Web application available (default_host): http://479c9c236b5f:9080/IIT/
[AUDIT ] CWWKZ0001I: Application IIT started in 10.076 seconds.
[AUDIT ] CWWKF0012I: The server installed the following features: [appSecurity-2.0, appSecurity-3.0, cdi-2.0, distributedMap-1.0, el-3.0, federatedRegistry-1.0, jndi-1.0, jsp-2.3, ldapRegistry-3.0, localConnector-1.0, samlWeb-2.0, servlet-4.0, ssl-1.0, transportSecurity-1.0].
[AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 26.691 seconds.
I used command docker run -p 8080:8080 my-docker to run my image but when i hit http://localhost:8080/IIT/ in browser it errors our saying "Connection was reset".

I don't know much about spring-mvc, But as per your description it's look like in In container application using (http://479c9c236b5f:9080) 9080 port and outside you are using 8080 port.
Please apply docker run -p 8080:9080 my-docker for access it.
and if you are using Dockerfile please mention EXPOSE 9080 in Dockerfile also.

Related

AIRFLOW: cannot run springboot application on airflow container

I am trying to run a springboot application in airflow container but stops saying the http webserver stopped on the port. Can I run an embedded process on airflow container on a different port?

Docker hub jhipster-registry not accessible on port 8761

I have recently started exploring the microservice architecture using jhipster and was trying to install and run the jhipster-registry from docker hub. Docker shows that the registry is running, but I am unable to access it on port 8761.
Pulled the image with docker pull jhipster/jhipster-registry
Started the container with docker run --name jhipster-registry -d jhipster/jhipster-registry
Here's a snapshot of what docker container ls returns:
Am I missing something over here?
You are starting the JHipster Registry container, but you aren't exposing the port.
You can expose a port by passing the port flag -p 8761:8761 which will enable you to connect to it via localhost:8761 or 127.0.0.1:8761 in a browser.
You may need to configure some environment variables for the JHipster Registry to start correctly. These may depend on your generated app's options, such as authentication type. For convenience JHipster apps come with a docker-compose.yml file. You can start it with docker-compose -f src/main/docker/jhipster-registry.yml up, as documented.

docker image running not able to access api in spring boot gradle

I have created a image of spring boot gradle project by using command gradlew jibDockerBuild
I run the image by this command docker run -p 8082:8082 demo:0.0.1-SNAPSHOT.Image is running successfully on port 8082.In project application.properties server.port is 8082 only.
I am not able accesss api so I have checked in my machine whether this process is running on the port or not by command netstat -a -n -o | find "8082".No process is running on that port.
When you install Docker on Windows by Docker Toolbox by default Docker will run on 192.168.99.100 IP (DOCKER_IP).
You can access all your containers running inside docker with DOCKER_IP on your Host machine ie Windows.
Read more on it here
Regarding your mapping query
You have mapped port, which means your container port will be mapped to DOCKER_IP:PORT
If you were using Docker on Linux or Mac it will get mapped to localhost:port as in those cases Docker is running on localhost.
The same is not true for Windows at least with Docker Toolbox.
As per your configuration, you can access your application on HOST machine by hitting
http://192.168.99.100:8082

docker ports not available

I have a spring-config-sever project that I am trying to run via Docker. I can run it from the command line and my other services and browser successfully connect via:
http://localhost:8980/aservice/dev
However, if I run it via Docker, the call fails.
My config-server has a Dockerfile:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE=build/libs/my-config-server-0.1.0.jar
ADD ${JAR_FILE} my-config-server-0.1.0.jar
EXPOSE 8980
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/my-config-server-0.1.0.jar"]
I build via:
docker build -t my-config-server .
I am running it via:
docker run my-config-server -p 8980:8980
And then I confirm it is running via
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1cecafdf99fe my-config-server "java -Djava.securit…" 14 seconds ago Up 13 seconds 8980/tcp suspicious_brahmagupta
When I run it via Docker, the browse fails with a "ERR_CONNECTION_REFUSED" and my calling services fails with:
Could not locate PropertySource: I/O error on GET request for
"http://localhost:8980/aservice/dev": Connection refused (Connection
refused);
Adding full answer based on comments.
First, you have to specify -p before image name.
docker run -p 8980:8980 my-config-server.
Second, just configuring localhost with host port won't make your my-service container to talk to other container. locahost in container is within itself(not host). You will need to use appropriate docker networking model so both containers can talk to each other.
If you are on Linux, the default is Bridge so you can configure my-config-server container ip docker inspect {containerIp-of-config-server} as your config server endpoint.
Example if your my-config-server ip is 172.17.0.2 then endpoint is - http://172.17.0.2:8980/
spring:
cloud:
config:
uri: http://172.17.0.2:8980
Just follow the docker documentation for little bit more understanding on how networking works.
https://docs.docker.com/network/network-tutorial-standalone/
https://docs.docker.com/v17.09/engine/userguide/networking/
If you want to spin up both containers using docker-compose, then you can link both containers using service name. Just follow Networking in Compose.
I could imagine that the application only listens on localhost, ie 127.0.0.1.
You might want to try setting the property server.address to 0.0.0.0.
Then port 8980 should also be available externally.

Can't connect to Neo

I've installed Docker on OSX and downloaded the neo image. when I run it (using the args in the home page of the image), everything seems to work, but the last lines of the log indicate something like:
00:20:39.662 [main] INFO org.eclipse.jetty.server.Server - Started
#4761ms 2015-10-05 00:20:39.663+0000 INFO [API] Server started on:
http://022b5f3a38fc:7474/ 2015-10-05 00:20:39.663+0000 INFO [API]
Remote interface ready and available at [http://022b5f3a38fc:7474/]
which seem odd and attempting to connect my browser to either http://localhost:7474/ or the indicated http://022b5f3a38fc:7474/ results in an error
what am I missing here?
You'll want to use the IP address of the docker VM, which you can determine with this command:
docker-machine inspect default | grep IPAddress
The default IP address is 192.168.99.100
So depending on which port you exposed when running the Neo4j docker container you can access the Neo4j browser at:
http://192.168.99.100:7474
or
http://192.168.99.100:8474
Port 8474 is the the binding specified by this command:
docker run -i -t --rm --name neo4j -v $HOME/neo4j-data:/data -p 8474:7474 neo4j/neo4j
which is the example given in the documentation here

Resources