2

I m a beginner in docker.

I wish to deploy an java ant war application using docker

I have installed docker in server1

Created a Dockerfile :

FROM java:8
EXPOSE 8116
ADD myapp.war myapp.war
ADD jetty-runner-9.4.8.v20171121.jar jetty-runner-9.4.8.v20171121.jar
RUN mkdir temp_dir
CMD ["nohup", "java" , "-Dorg.eclipse.jetty.server.Request.maxFormContentSize=10000000" , "-Xms64m" , "-Xmx128m" , "-Djava.io.tmpdir=temp_dir" , "-jar" ,"jetty-runner-9.4.8.v20171121.jar" ,"--log" ,"myapp-docker-request.log" ,"--out","myapp-docker-output.log" ,"--port" , "8116",  "--path" , "/myapp-docker" ,"myapp.war" , "&" ]

build the image as :

docker build -t  myapp .

run as :

docker run -p 8116:8116 myapp

while listing :

[root@metafore-staging ~]# docker ps --all
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
068751d27d8f        myapp               "nohup java -Dorg.ecl"   9 seconds ago       Exited (1) 7 seconds ago                        berserk_lovelace

It is not get started ; reports as :

[root@localhost ~]# docker run -p 8116:8116 myapp

2017-12-15 11:21:50.653:INFO::main: Logging initialized @148ms to org.eclipse.jetty.util.log.StdErrLog
2017-12-15 11:21:50.661:INFO:oejr.Runner:main: Runner
2017-12-15 11:21:50.729:INFO:oejr.Runner:main: Redirecting stderr/stdout to myapp-docker-output.log

I wish to check the deployed app (myapp) in the browser , using http://server1:8116 (Docker application were deployed in Server1)

I have deployed the myapp in the server1 directly to check the working , it works fine . Need to deploy and check it using docker

soundararajan.c
  • 2,538
  • 6
  • 29
  • 51
  • see https://stackoverflow.com/questions/37461868/whats-the-difference-between-run-and-cmd-in-a-docker-file-and-when-should-i-use – Davide Cavestro Dec 15 '17 at 10:55
  • updated the question; – soundararajan.c Dec 15 '17 at 11:30
  • 1
    I don't think you need the nohup since that would put it in the background. Since nothing is running in the foerground the docker container would stop. same with the & at end. The job needs to be running in the foreground to keep the container running. – dskow Dec 15 '17 at 15:46
  • Yes ,now it's running.I need to run the container in background of the server. i have appended "-D", "BACKGROUND" in the docker file,now container was running in the background ,i can check the java application in the URL . but in the server after executing the docker run cmd it reports as : `/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint jovial_mccarthy (37d07c7c3d0bc327695091e9df4132b39967d23c5d302e97120710364a124cc5): Bind for 0.0.0.0:8116 failed: port is already allocated.`with out -D BACKGROUND` it is not showing any error – soundararajan.c Dec 18 '17 at 06:11
  • `[root@localhost ~]# docker ps -all CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cd78ce9c0135 myapp "java -Dorg.eclipse.j" 7 minutes ago Created jovial_mccarthy` status not showing as running. with out "-D", "BACKGROUND" status shows running and port shown as 8116-->8116 tcp – soundararajan.c Dec 18 '17 at 06:13

0 Answers0