Docker Compose to CoreOS Docker Compose to CoreOS docker docker

Docker Compose to CoreOS


taken from https://docs.docker.com/compose/install/

the only thing is that /usr is read only, but /opt/bin is writable and in the path, so:

sd-xx~ # mkdir /opt/sd-xx~ # mkdir /opt/binsd-xx~ # curl -L https://github.com/docker/compose/releases/download/1.3.3/docker-compose-`uname -s`-`uname -m` > /opt/bin/docker-compose  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed100   403    0   403    0     0   1076      0 --:--:-- --:--:-- --:--:--  1080100 7990k  100 7990k    0     0  2137k      0  0:00:03  0:00:03 --:--:-- 3176ksd-xx~ # chmod +x /opt/bin/docker-composesd-xx~ # docker-composeDefine and run multi-container applications with Docker.Usage:  docker-compose [options] [COMMAND] [ARGS...]  docker-compose -h|--helpOptions:  -f, --file FILE           Specify an alternate compose file (default: docker-compose.yml)  -p, --project-name NAME   Specify an alternate project name (default: directory name)  --verbose                 Show more output  -v, --version             Print version and exitCommands:  build              Build or rebuild services  help               Get help on a command  kill               Kill containers  logs               View output from containers  port               Print the public port for a port binding  ps                 List containers  pull               Pulls service images  restart            Restart services  rm                 Remove stopped containers  run                Run a one-off command  scale              Set number of containers for a service  start              Start services  stop               Stop services  up                 Create and start containers  migrate-to-labels  Recreate containers to add labels


I've created simple script for installing latest Docker Compose on CoreOS:https://gist.github.com/marszall87/ee7c5ea6f6da9f8968dd

#!/bin/bashmkdir -p /opt/bincurl -L `curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.assets[].browser_download_url | select(contains("Linux") and contains("x86_64"))'` > /opt/bin/docker-composechmod +x /opt/bin/docker-compose

Just run it with sudo


The proper way to install or run really anything on CoreOS is either

  1. Install it as a unit
  2. Run in a separate docker container

For docker-compose you probably want to install it as a unit, just like you have docker as a unit. See Digital Ocean's excellent guides on CoreOS and the systemd units chapter to learn more.

Locate your cloud config based on your cloud provider or custom installation, see https://coreos.com/os/docs/latest/cloud-config-locations.html for locations.

Install docker-compose by adding it as a unit

#cloud-configcoreos:  units:    - name: install-docker-compose.service      command: start      content: |        [Unit]        Description=Install docker-compose        ConditionPathExists=!/opt/bin/docker-compose        [Service]        Type=oneshot        RemainAfterExit=yes        ExecStart=/usr/bin/mkdir -p /opt/bin/        ExecStart=/usr/bin/curl -o /opt/bin/docker-compose -sL "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-linux-x86_64"        ExecStart=/usr/bin/chmod +x /opt/bin/docker-compose

Note that I couldn't get the uname -s and uname -m expansions to work in the curl statement so I just replaced them with their expanded values.

Validate your config file with

coreos-cloudinit -validate --from-file path-to-cloud-config

It should output something like

myhost core # coreos-cloudinit -validate --from-file path-to-cloudconfig2016/12/12 12:45:03 Checking availability of "local-file"2016/12/12 12:45:03 Fetching user-data from datasource of type "local-file"myhost core #

Note that coreos-cloudinit doesn't validate the contents-blocks in your cloud-config. Restart CoreOS when you're finished, and you're ready to go.

Update: As @Wolfgang comments, you can run coreos-cloudinit --from-file path-to-cloud-config instead of restarting CoreOS.