Second unit in cloud-config will not start.

44 views
Skip to first unread message

Adrian

unread,
Jul 18, 2016, 6:21:18 AM7/18/16
to CoreOS User
Hi,

I am experiencing some weird behavior with docker, coreos and cloud-config. I have configured two units in my cloud-config, both are docker instances that need to be started on boot. When I provision a new server both unit files are created but only one is started. The weird thing is it always the first one in the configuration. So if change the order in the configuration the problem still exist it is just the other container that does not start.

Does anybody have a clue why this could be happening?

My configuration:

#cloud-config

hostname: "registry.example.com"
coreos:
  units:
    - name: "registry.service"
      command: "start"
      enable: true
      runtime: true
      content: |
        [Unit]
        Description=Private Docker registry
        After=docker.service
        Requires=docker.service

        [Service]
        Restart=always
        TimeoutStartSec=0
        ExecStartPre=-/usr/bin/docker kill registry
        ExecStartPre=-/usr/bin/docker rm registry
        ExecStart=/usr/bin/docker pull registry
        ExecStartPost=/usr/bin/docker run --name registry registry:2
        ExecStop=/usr/bin/docker stop registry

        [Install]
        WantedBy=multi-user.target
    - name: "redis.service"
      command: "start"
      enable: true
      runtime: true
      content: |
        [Unit]
        Description=Redis container
        After=docker.service
        Requires=docker.service

        [Service]
        Restart=always
        TimeoutStartSec=0
        ExecStartPre=-/usr/bin/docker kill redis
        ExecStartPre=-/usr/bin/docker rm redis
        ExecStart=/usr/bin/docker pull redis
        ExecStartPost=/usr/bin/docker run --name redis redis
        ExecStop=/usr/bin/docker stop redis

        [Install]
        WantedBy=multi-user.target

Ivan

unread,
Jul 20, 2016, 11:06:22 PM7/20/16
to CoreOS User
cloud-config does not get a "Result of "start" on "registry.service": done" and as a result does not start "redis.service".

This cloud-config should work:


#cloud-config

hostname: "registry.example.com"
coreos:
  units:
    - name: "registry.service"
      command: "start"
      enable: true
      runtime: true
      content: |
        [Unit]
        Description=Private Docker registry
        After=docker.service
        Requires=docker.service

        [Service]
        Restart=always
        TimeoutStartSec=0
        ExecStartPre=-/usr/bin/docker kill registry
        ExecStartPre=-/usr/bin/docker rm registry
        ExecStartPre=/usr/bin/docker pull registry
        ExecStart=/usr/bin/docker run --name registry registry:2

        ExecStop=/usr/bin/docker stop registry

        [Install]
        WantedBy=multi-user.target
    - name: "redis.service"
      command: "start"
      enable: true
      runtime: true
      content: |
        [Unit]
        Description=Redis container
        After=docker.service
        Requires=docker.service

        [Service]
        Restart=always
        TimeoutStartSec=0
        ExecStartPre=-/usr/bin/docker kill redis
        ExecStartPre=-/usr/bin/docker rm redis
        ExecStartPre=/usr/bin/docker pull redis
        ExecStart=/usr/bin/docker run --name redis redis

        ExecStop=/usr/bin/docker stop redis

        [Install]
        WantedBy=multi-user.target

For troubleshooting purposes, journalctl --identifier=coreos-cloudinit shows coreos-cloudinit run output that triggered by system boot.

Adrian

unread,
Jul 22, 2016, 8:34:31 AM7/22/16
to CoreOS User
Thanks Ivan,

I already solved it by splitting it up in multiple unit files. But will add the journalctl command to cheat sheet :)
Reply all
Reply to author
Forward
0 new messages