I'm currently getting into Docker (or trying to), so I set up a little webapp. I used Eclipse to create a maven-Project, built a .war-file and deployed it (to check if it works) locally on a Glassfish server. This worked, and I could access the webapp via
localhost:8080/myApp
Now I created a Dockerfile, built a docker image from that and ran the whole thing via
docker run -d -p 8080:8080 myApp
This also works, and
docker ps -a
shows that a container is running. However, when I try to access localhost:8080/myApp now, I get
ERR_CONNECTION_REFUSED
I tried this with Chrome, Firefox and Internet Explorer.
docker exec -it <myContainer> bash
gives me a shell inside the container (as expected). When I do
curl -v localhost:8080/myApp
here, I get the output I expect (the page from myApp).
So for me, this means that the container is running, the glassfish server is running inside the container, and myApp has been deployed "properly" to said server, yet still I cannot access myApp from outside the container.
docker ps -a
yields this, btw:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9514b1ab6dd0 myApp "sh /start.sh" 9 minutes ago Up 9 minutes 4848/tcp, 8181/tcp, 0.0.0.0:8080->8080/tcp admiring_cori
The Dockerfile does of course contain the line
EXPOSE 8080
Any ideas what might be wrong here?
Edit:
These are the contents of the Dockerfile:
FROM glassfish:4.0
COPY myApp.war /
COPY start.sh /
EXPOSE 8080
RUN ["chmod", "+x", "/start.sh"]
ENTRYPOINT ["sh", "/start.sh"]
start.sh:
#!/bin/sh
/usr/local/glassfish4/bin/asadmin start-domain
/usr/local/glassfish4/bin/asadmin -u admin deploy /myApp.war
/usr/local/glassfish4/bin/asadmin stop-domain
/usr/local/glassfish4/bin/asadmin start-domain --verbose
Edit 2:
docker logs <container>
yields
Waiting for domain1 to start ...............
Successfully started the domain : domain1
domain Location: /usr/local/glassfish4/glassfish/domains/domain1
Log File: /usr/local/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
Application deployed with name myApp.
Command deploy executed successfully.
Waiting for the domain to stop .
Command stop-domain executed successfully.
Launching GlassFish on Felix platform
Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime@2ba2f40 in service registry.
Registry Info:: Total repositories: 1, Total modules = 293
Attached repository: []
[... Registered Modules... all with State = [NEW] or [RESOLVED]]
Found populator: com.sun.enterprise.v3.server.GFDomainXml
#!## LogManagerService.postConstruct : rootFolder=/usr/local/glassfish4/glassfish
#!## LogManagerService.postConstruct : templateDir=/usr/local/glassfish4/glassfish/lib/templates
#!## LogManagerService.postConstruct : src=/usr/local/glassfish4/glassfish/lib/templates/logging.properties
#!## LogManagerService.postConstruct : dest=/usr/local/glassfish4/glassfish/domains/domain1/config/logging.properties