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).

  • Apache Storm FileNotFoundException in Cluster Mode
  • Extracting Docker Container to an bootable hdd disk
  • Multilayer Docker Deployment on AWS
  • How to get container and image name when using fluentd for docker logging?
  • Nginx proxy on Elastic Beanstalk EC2 instance times out
  • When will Docker be launched? [closed]
  • 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 can I gdb attach to a process running in a docker container?
  • Running a Python script automatically when launching a Docker container
  • docker-compose does not see volumes changes in docker-compose.yml
  • Manage docker container security patchs
  • Why I can't see my files inside a docker container?
  • Docker and Splash to render website does not work
  • One Solution collect form web for “Run two services in same Docker container on CoreOS?”

    Brooks, Good news. I have an example ( https://github.com/brianredbeard/memcache-tools ) of just that which was written using CoreOS.

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

    Memcache.service unit:

    [Unit]
    Description=My Memcached Server
    Requires=docker.service
    After=docker.service
    
    [Service]
    ExecStart=/usr/bin/docker run --rm --name %n -t -i memcache
    

    Worker.service unit:

    [Unit]
    Description=My worker container
    Requires=Memcache.service
    After=Memcache.service
    
    [Service]
    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 README.md in that example.

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