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

  • Linux Container vs JVM
  • Define application properties on build using Spring Boot and Maven
  • What purpose does using exec in docker entrypoint scripts serve?
  • Increment command timeout in EBS from the -AWS
  • ElasticSearch in docker
  • Hapi.js is not listening to subdomains?
  • 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?

  • Replication of MySQL database between docker swarm clusters
  • crash error when execute docker-compose
  • Image name dropdown is empty when configuring remote interpreter Docker in PyCharm 2016
  • Terraform unable to get docker to join swarm
  • What docker image use for ionic CD / e2e testing? Ubuntu or just node?
  • Docker-compose mysql: import .sql
  • 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.