CoreOS overview

This blog is part of my ongoing series on Docker containers. In this blog, I will cover basics of CoreOS and some hands-on stuff I tried with CoreOS. As mentioned in my other blog on Docker  orchestration, CoreOS falls in the category of specialized Linux distributions that can host Containers and are suitable for massive server deployments.

CoreOS is a Linux distribution with very minimal services installed and the primary goal is to have a scalable clustering system. Following 2 pictures from CoreOS shows the details from both single host perspective as well as Cluster perspective.



Following are some notes regarding the architecture of CoreOS.

  • The base linux distribution has minimal services on top of which Containers are hosted.
  • The 4 main services are etcd, systemd/fleet, docker, flannel.
  • etcd is a distributed key, value store that is used for service discovery. The key, value can be read and written from any of the host systems as well as the containers running inside the host systems. Examples could be service port numbers, database details etc.
  • Fleet is a service orchestrator that schedules the containers across CoreOS cluster based on different constraints. Fleet uses systemd that runs in each host.
  • Docker is the Container manager that runs the containers.
  • Flannel is used for networking containers across hosts so that containers across hosts can talk to each other.

CoreOS Install:

I installed a CoreOS cluster on my Windows 7 machine running Vagrant and Virtualbox using the procedure here. “user-data” file specifies the cloud-config that contains the services that needs to be started during the system init. Default cloud-config provided starts etcd, fleet and docker.

To verify individual CoreOS services, I tried the following:


etcd repository can be accessed either from http json interface or by using etcdctl cli interface. There is 1 master host elected and the other hosts remain as slaves. The key, value repository can be accessed from any host and the integrity is always maintained.

Following command shows the etcd machines in the cluster. Here, “” machine is the leader, “” and “” are the followers.

core@core-01 ~/.ssh $ curl -L

Following example shows how to read the complete key hierarchy:

core@core-01 ~/.ssh $ etcdctl ls / --recursive

Following example shows how to write a new key, value pair and how to read it.

core@core-01 ~/.ssh $ curl -L -d value="Hello world"
{"action":"set","key":"/message","value":"Hello world","newKey":true,"index":136226}
core@core-01 ~/.ssh $ curl -L
{"action":"get","key":"/message","value":"Hello world","index":136247}
core@core-01 ~/.ssh $ etcdctl ls / --recursive


Fleet is the cluster manager that is responsible for orchestration of containers into the cluster of hosts. Fleet allows to treat the entire cluster as a single system. Fleet interacts with systemd in each individual host. Fleetctl is the interface used by Fleet.

Following command shows the machines in the cluster that fleet is managing.

core@core-01 ~ $ fleetctl list-machines
MACHINE         IP              METADATA
52f5bf74...    -
8b3786a9...    -
ff59286c...    -

Lets walk thru an example to load a service and start it. Following command shows the current services running. Each unit is like a service. Currently, no services are running.

core@core-01 ~ $ fleetctl  list-units

Lets create a new service called hello.service.

core@core-01 ~ $ cat hello.service
Description=My Service

ExecStartPre=-/usr/bin/docker kill hello
ExecStartPre=-/usr/bin/docker rm hello
ExecStartPre=/usr/bin/docker pull busybox
ExecStart=/usr/bin/docker run --name hello busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done"
ExecStop=/usr/bin/docker stop hello

In the first section(Unit), we define the description of the service along with the constraint that this service needs to be started after docker is started. Thats because hello.service is launched by docker and it needs to be available before. “ExecStartPre” section defines what needs to be done before hello.service is launched. We need to kill any previous instances of hello service and pull the busybox container where hello service will be run from. “ExecStart” section specifies the docker command to start the busybox container and run an infinite loop of echo command.

Lets first load the service. Fleet has decided to host the container on

core@core-01 ~ $ fleetctl load hello.service
Unit hello.service loaded on 52f5bf74.../
core@core-01 ~ $ fleetctl  list-units
UNIT            MACHINE                         ACTIVE          SUB
hello.service   52f5bf74.../        inactive        dead

Now, lets start the service.

core@core-01 ~ $ fleetctl start hello.service
Unit hello.service launched on 8b3786a9.../
core@core-01 ~ $ fleetctl  list-units
UNIT            MACHINE                         ACTIVE  SUB
hello.service   8b3786a9.../        active  running

The following command shows the status of hello.service. The status also shows the last 10 lines of the output of hello.service.

core@core-01 ~ $ fleetctl status hello.service
● hello.service - My Service
   Loaded: loaded (/run/fleet/units/hello.service; linked-runtime; vendor preset: disabled)
   Active: active (running) since Fri 2015-01-16 15:58:48 UTC; 49s ago
  Process: 1483 ExecStartPre=/usr/bin/docker pull busybox (code=exited, status=0/SUCCESS)
  Process: 1473 ExecStartPre=/usr/bin/docker rm hello (code=exited, status=0/SUCCESS)
  Process: 1464 ExecStartPre=/usr/bin/docker kill hello (code=exited, status=0/SUCCESS)
 Main PID: 1495 (docker)
   CGroup: /system.slice/hello.service
           └─1495 /usr/bin/docker run --name hello busybox /bin/sh -c while true; do echo Hello World; sleep 1; done

Jan 16 15:59:28 core-02 docker[1495]: Hello World
Jan 16 15:59:29 core-02 docker[1495]: Hello World
Jan 16 15:59:30 core-02 docker[1495]: Hello World
Jan 16 15:59:31 core-02 docker[1495]: Hello World
Jan 16 15:59:32 core-02 docker[1495]: Hello World
Jan 16 15:59:33 core-02 docker[1495]: Hello World
Jan 16 15:59:34 core-02 docker[1495]: Hello World
Jan 16 15:59:35 core-02 docker[1495]: Hello World
Jan 16 15:59:36 core-02 docker[1495]: Hello World
Jan 16 15:59:37 core-02 docker[1495]: Hello World


We can try running a simple container to make sure that Docker is running. Following example shows running a sample ubuntu container.

core@core-01 ~ $ sudo docker run -ti ubuntu /bin/bash


Flannel(Previously called Rudder) is used to network the containers running in hosts that are part of the CoreOS cluster. This allows containers on 1 host to talk to another. I will cover details on Flannel in my next blog.


3 thoughts on “CoreOS overview

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s