How can write Dockerfile to start a webserver and curl it for some requirements

I’d like to use this dockerfile naively.

FROM test/tomcat
RUN ${CATALINA_HOME}/bin/ start
RUN wget localhost:8080/Writer/WriterServlet

The result is as follows certainly

  • How do I run docker-compose up on a a docker-swarm?
  • docker-machine create error … VBoxManage: error: Unknown option: --synthcpu
  • Connecting from psycopg2 on local machine to PostgreSQL db on Docker
  • Docker volumes mount binding permissions difference between maven build and docker cli
  • Docker Hello World fails
  • fossology docker image fails to start
  • docker build --no-cache=true - < Dockerfile
    Sending build context to Docker daemon 3.072 kB
    Sending build context to Docker daemon
    Step 0 : FROM test/tomcat
     ---> 2a85ccb3dd07
    Step 1 : ENV CATALINA_HOME /tomcat
     ---> Running in 76872d1acdd5
     ---> 30ad1fe832d6
    Removing intermediate container 76872d1acdd5
    Step 2 : RUN ${CATALINA_HOME}/bin/ start
     ---> Running in 5947560a3428
    Tomcat started.
     ---> ea670dd1d3ff
    Removing intermediate container 5947560a3428
    Step 3 : RUN wget localhost:8080/Writer/WriterServlet
     ---> Running in 6aa5c9be8569
    --2014-12-19 03:08:16--  http://localhost:8080/Writer/WriterServlet
    Resolving localhost (localhost)... ::1,
    Connecting to localhost (localhost)|::1|:8080... failed: Connection refused.
    Connecting to localhost (localhost)||:8080... failed: Connection refused.
    2014/12/19 11:08:16 The command [/bin/sh -c wget localhost:8080/Writer/WriterServlet] returned a non-zero code: 4

    In this case, tomcat offer some interface to write a file, so I need to build through the tomcat server.

    Maybe because the wget can’t wait tomcat to start up.

    Or because docker’s layered container structure cause that when in step 3(wget), the tomcat down again.

    So my question in summary is, can I write a docker build to keep some process run together for the interactive requirements?

  • unable to start docker after upgrading to 1.12 version
  • How do I add big HTTP files in a Dockerfile and exclude them from image layers?
  • Docker orchestration
  • Apache Tomcat 8 not starting within a docker container
  • Pull private docker images from Google Container Registry w/o gcloud
  • Job tracker is not starting up
  • One Solution collect form web for “How can write Dockerfile to start a webserver and curl it for some requirements”

    Docker file build steps do not maintain a running container or systme. Each line makes a change to the file system, docker stores the changes to the file system only. Any processes that are started are discarded.

    Docker can only start long running processes when a container is run (not when a container is being built). You need to use ENTRYPOINT or CMD to call a custom script at container startup. This script will start tomcat and run the wget and make any changes needed before starting a long running process such as a tail on tomcat logs.

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