How to deploy web service on Docker container

This is my Dockerfile:

#Build java web app container image
FROM ubuntu
#Make java and tomcat install directory
RUN mkdir /usr/local/java
RUN mkdir /usr/local/tomcat
#Copy jre and tomcat into image
ADD jdk1.8.0_45.jdk /usr/local/java/
ADD apache-tomcat-7.0.62 /usr/local/tomcat/
ENV JAVA_HOME=/usr/local/java/Contents/Home
CMD cd /usr/local/tomcat;./bin/ run
#Expose http port

Then i built it and try to start it:

  • How can I use a docker container with a self signed certificate on osx?
  • Building Docker images using Jenkins results in “Unsupported protocol scheme found”
  • “AH01071: Got error 'Unable to open primary script”: Container permissions or Symfony3 issue?
  • Node and docker - how to handle babel or typescript build?
  • how can docker containers have a different flavor than the host
  • Image of a data volume using docker
  • wangyaos-MBP-3:flexcloud wangyao$ ls
    Dockerfile      apache-tomcat-7.0.62    jdk1.8.0_45.jdk
    wangyaos-MBP-3:flexcloud wangyao$ docker build -t flexcloud .
    Sending build context to Docker daemon 355.6 MB
    Sending build context to Docker daemon 
    Successfully built 1f824d246b39
    wangyaos-MBP-3:flexcloud wangyao$ docker run -i -t flexcloud
    Using CATALINA_BASE:   /usr/local/tomcat
    Using CATALINA_HOME:   /usr/local/tomcat
    Using CATALINA_TMPDIR: /usr/local/tomcat/temp
    Using JRE_HOME:        /usr/local/java/Contents/Home
    Using CLASSPATH:        /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
    /usr/local/java/Contents/Home/bin/java: 20: /usr/local/java/Contents/Home/bin/java: Syntax error: word unexpected (expecting ")")
    wangyaos-MBP-3:flexcloud wangyao$ 

    what does word unexpected (expecting ")") mean ?

    I used $ ./bin/ run without docker, and I can run it, but i why can not run it on the docker container ?

  • Docker secrets and Compose compatibility issue
  • Is there a way to download docker hub images whitout “docker pull” for a machine with out Internet access?
  • How to ssh to a docker container on ec2 ubuntu host from outside machine
  • How to run aiohttp with gunicorn in docker container?
  • Docker django Import Error : No module named 'social'
  • How to get container image's tags list?
  • One Solution collect form web for “How to deploy web service on Docker container”

    As indicated in the comments, the error Syntax error: word unexpected (expecting ")") is a shell script error, which implies that /usr/local/java/Contents/Home/bin/java is not actually the java executable.

    Accessing the container with docker exec -it <container> bash and executing /usr/local/java/Contents/Home/bin/java -version shows us whats actually going on, as per @KingOfSocket’s comment.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.