-1

I am new to Docker

Docker version 18.03.0-ce, build 0520e24 running on RHEL 7.

I created a simple ReST service using the Spring tutorial. The uber jar runs fine on my windows machine and I am able to access the service via the browser.

The Dockerfile:

# fetch basic image
FROM openjdk:latest

# application placed into /opt/app
RUN mkdir -p /opt/app
WORKDIR /opt/app

# local application port
EXPOSE 8080

Now, I executed the following steps

1.Build the image

docker build --tag=java-rest

2.Run the container

docker run -p 18080:8080 -t -i java-rest

3.Check if the container is up

[root@l5341t ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                          PORTS                     NAMES
38ec56c99135        java-rest           "bash"              About a minute ago   Up About a minute               0.0.0.0:18080->8080/tcp   infallible_yalow

4.Copy the jar file to the container

docker cp /localhome/ojoqcu/code/java/gs-rest-service-0.1.0.jar 38ec56c99135:/opt/app/gs-rest-service-0.1.0.jar

5.Run the container and also the jar

docker run -p 18080:8080 -t -i java-rest
root@38ec56c99135:/opt/app# ls
gs-rest-service-0.1.0.jar
root@38ec56c99135:/opt/app#
root@38ec56c99135:/opt/app#
root@38ec56c99135:/opt/app# java -jar gs-rest-service-0.1.0.jar

6.On the container, the application is running

root@38ec56c99135:/opt/app# ps -eaf
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 13:43 pts/0    00:00:00 bash
root         8     1  0 13:47 pts/0    00:00:14 java -jar gs-rest-service-0.1.0.
root        54     0  0 14:16 pts/1    00:00:00 bash
root        60    54  0 14:17 pts/1    00:00:00 ps -eaf

The responses:

1.From the same machine(RHEL 7)

[root@l5341t ~]# curl http://localhost:18080
<HTML>
<HEAD><TITLE>Redirection</TITLE></HEAD>
<BODY><H1>Redirect</H1></BODY>
[root@l5341t ~]#



[root@l5341t ~]# curl http://0.0.0.0:18080
<HTML><HEAD>
<TITLE>Network Error</TITLE>
</HEAD>
<BODY>
<FONT face="Helvetica">
<big><strong></strong></big><BR>
</FONT>
<blockquote>
<TABLE border=0 cellPadding=1 width="80%">
<TR><TD>
<FONT face="Helvetica">
<big>Network Error (tcp_error)</big>
<BR>
<BR>
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
A communication error occurred: ""
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica" SIZE=2>
<BR>
For assistance, contact your network support team.
</FONT>
</TD></TR>
</TABLE>
</blockquote>
</FONT>
</BODY></HTML>
[root@l5341t ~]#



[root@l5341t ~]# curl http://l5341t:18080
<HTML><HEAD>
<TITLE>Network Error</TITLE>
</HEAD>
<BODY>
<FONT face="Helvetica">
<big><strong></strong></big><BR>
</FONT>
<blockquote>
<TABLE border=0 cellPadding=1 width="80%">
<TR><TD>
<FONT face="Helvetica">
<big>Network Error (dns_unresolved_hostname)</big>
<BR>
<BR>
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
Your requested host "l5341t" could not be resolved by DNS.
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">

</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica" SIZE=2>
<BR>
For assistance, contact your network support team.
</FONT>
</TD></TR>
</TABLE>
</blockquote>
</FONT>
</BODY></HTML>
[root@l5341t ~]#
[root@l5341t ~]#

2.From my local Windows machine's browser(I think it's still hitting the Spring Boot's embedded server but unsure!)

http://l5341t:18080/
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu May 24 14:13:44 UTC 2018
There was an unexpected error (type=Not Found, status=404).
No message available
0

I ain't digging deeper in the Spring code(it works perfectly on WIndows/Linux machines but not in the container!) but it seems that the issue is really with the code and not the Docker config. I found an answer here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.