Unable to run Tomcat 7 as service inside container on CoreOS

I am trying to setup tomcat 7 on Digital Ocean CoreOS machine but facing some problem, not sure how to solve them. I am following below tutorial provided by the Digital Ocean to setup Apache.


  • Does hub.docker.com use “--no-cache” for automated builds?
  • “Error reading data” while executing a RabbitMQ consumer in Symfony
  • How can I access from outside my docker container in mac?
  • Docker container doesnot reflect changes on machines other than it was created
  • Can a dockerfile interact with system settings?
  • Jenkins Docker Container can't access docker.sock
  • I created docker container and run it using following command.

    docker run -i -t ubuntu:14.04 /bin/bash

    I was successfully able to install tomcat 7 by using below commands. (I followed this tutorial to setup tomcat 7 within the docker container: https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-ubuntu-14-04-via-apt-get)

    sudo apt-get update 
    sudo apt-get install tomcat7

    Then I can created service unit file named as tomcat@.service

    Description=Tomcat 7 web server service 
    After=etcd.service After=docker.service     
    TimeoutStartSec=0 KillMode=none 
    ExecStartPre=-/usr/bin/docker kill tomcat%i 
    ExecStartPre=-/usr/bin/docker rm tomcat%i 
    ExecStartPre=/usr/bin/docker pull attacomsian/tomcat 
    ExecStart=/usr/bin/docker run –name tomcat%i -p ${COREOS_PUBLIC_IPV4}:%i:8080 attacomsian/tomcat `service tomcat7 start` -D FOREGROUND 
    ExecStop=/usr/bin/docker stop tomcat%i

    Then I created tomcat-discovery@.service to register service states with Etcd as below

    Description=Announce Tomcat@%i service 
    ExecStart=/bin/sh -c “while true; do etcdctl set /announce/services/tomcat%i ${COREOS_PUBLIC_IPV4}:%i –ttl 60; sleep 45; done” 
    ExecStop=/usr/bin/etcdctl rm /announce/services/tomcat%i

    I submitted and loaded files to Fleet as below

    fleetctl submit tomcat@.service tomcat-discovery@.service
    fleetctl load tomcat@8080.service
    fleetctl load tomcat-discovery@8080.service

    Everything worked fine so far. I did not see any error. But when I tried to run the service as below

    fleetctl start tomcat@8080.service

    But it did not started. I can see it is appearing as dead.

    I am new to CoreOS and still learning. I am managing servers at Digital Ocean and I quite about it quite well. I googled about this issue but did not found any help. I personally think following line is actually causing the trouble.

    ExecStart=/usr/bin/docker run –name tomcat%i -p ${COREOS_PUBLIC_IPV4}:%i:8080 attacomsian/tomcat `service tomcat7 start` -D FOREGROUND

    I would really appreciate any kind help to get this up.

    Many Thanks


  • openssh-server doesn't start in Docker container
  • Why does “docker login” fail in Docker Quickstart Terminal but work from within the default machine?
  • How Docker calculates the hash of each layer? Is it deterministic?
  • Explanation of this docker file?
  • Should Swarm Master Join As Node in a Single Node Cluster?
  • Not able to login in docker private repositry
  • One Solution collect form web for “Unable to run Tomcat 7 as service inside container on CoreOS”

    I was going so suggest you take a look at what others have done and then discovered you have posted a similar question on the Docker Hub registry.

    Did you take a look at the Docker file used by the tutum/tomcat image?

    It runs a script called “run.sh” that runs tomcat in the foreground.

    The thing that is tricky to understand is that Docker is not a virtual machine and therefore does not have any services running. You must run the docker processes explicitly or setup a process manager like runit or supervisord.

    Hope this helps.

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