Run two services in same Docker container on CoreOS?

I’m kinda new to Docker and CoreOS. I think I’m just a bit unclear on the concept of containers and how they relate to each other.

I’m trying to set up a CoreOS-based server that runs two services: a custom server (call it myserver), and a memcached server (that will be accessed only by myserver).

  • Docker - Use IP instead of --link for communication
  • Microsoft Word crashes when invoking its COM inside Docker Container
  • how to run two web apps in the same localhost with same port in docker?
  • Dockerfile COPY instruction failing?
  • In Docker tomcat container tomcat is not running
  • No suitable driver found (jdbc:pgsql)
  • So I think I got as far as installing a myserver.service file on the CoreOS machine, that can successfully start upi myserver using a line like this:

    ExecStart=/bin/bash -c '/usr/bin/docker start -a my_container || /usr/bin/docker run --name my_container my-image /usr/local/bin/myserver'

    So my question is, in order to start up the memcached server, do I create a new memcached.service file in CoreOS? If so, should it use the same container “my_container” as the custom server? If they don’t use the same container, will myserver be able to reach the memcached server?

  • How to intercept the request from Spring Interceptor to Node Service
  • docker private registry within local network
  • Push in docker private registry
  • If docker uses virtual machine to run on a mac then what is its advantage over vagrant?
  • Can I Run a dotnet app which is hosted on IIS in a docker container?
  • Docker image with Maven fails to run
  • One Solution collect form web for “Run two services in same Docker container on CoreOS?”

    Brooks, Good news. I have an example ( ) of just that which was written using CoreOS.

    In this case you would have two containers with two systemd units.

    Memcache.service unit:

    Description=My Memcached Server
    ExecStart=/usr/bin/docker run --rm --name %n -t -i memcache

    Worker.service unit:

    Description=My worker container
    ExecStart=/usr/bin/docker run --rm --name %n -t -i --link memcache:memcache my_container

    What this will do is take the first container named memcache and present a number of variables into my_container in the form:
    MEMCAHCE_PORT_11211_TCP_???, e.g.MEMCAHCE_PORT_11211_TCP_HOST & MEMCAHCE_PORT_11211_TCP_PORT which can then be consumed inside your program.

    Take a look at the dump, load, and sample scripts as well as the Dockerfile and in that example.

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