Service Crashing Docker, Cannot Start

Day 1 Newbie here, go easy.

I know I’m Doing It Wrong™, because I don’t know the right way. Trying to get a grasp on The Right Way™ by playing around.

This service starts perfectly as a run command when I’m in the command-line after boot. So I tried to make it a service.yml file and start it on boot. Unfortunately, it crashes the docker daemon, console never starts, and I have to reimage it (on a Raspberry Pi).

If I use ros service enable path/file and then ros service start name nothing happens. I presume because something is bad.

I have created a service as follows (indentation is correct).

[rancher@rancher ~]$ cat /var/lib/rancher/conf/autossh.yml autossh: image: jnovack/rancher-autossh restart: never net: "host" privileged: true volumes: - /mnt/id_rsa:/id_rsa environment: - SSH_HOSTUSER=username - SSH_HOSTNAME=hostname

If you can give me some insight on what’s wrong here, and the better way to do it, I would appreciate any help.

Just to confirm. this is using RancherOS and not Rancher? Just want to put it in the right category.

Can you add in 3 backticks in front and back of your yaml file so I could see the indentation?

Can you list your exact commands and also run a sudo ros service list after you enable it?

After enabling it, you just need to run sudo ros service up -d <name> to start the service.

Denise,

Yes, RancherOS image that was created for the Raspberry Pi.

The problem was solved (worked-around?) by setting the following labels.

I didn’t really want it to start in the System-Docker, but it does work as expected now. Not sure it’s the right way, and it doesn’t solve any containers I want to start in the User-Docker automatically.

  labels:
    - io.rancher.os.after=network
    - io.rancher.os.scope=system
[rancher@rancher ~]$ sudo ros service list
disabled amazon-ecs-agent
disabled kernel-headers
disabled kernel-headers-system-docker
disabled open-vm-tools
enabled  /var/lib/rancher/conf/autossh.yml

I changed the container name, nothing else interesting.

[rancher@rancher ~]$ sudo cat /var/lib/rancher/conf/autossh.yml
autossh:
  image: jnovack/rpi-autossh
  net: "host"
  privileged: true
  labels:
    - io.rancher.os.after=network
    - io.rancher.os.scope=system
  volumes:
    - /mnt/id_rsa:/id_rsa
  environment:
    - SSH_USER=username
    - SSH_HOST=hostname

To initially set it up, I followed the official docs. http://docs.rancher.com/os/system-services/adding-system-services/

$ sudo ros service enable /var/lib/rancher/conf/autossh.yml
$ sudo reboot

And let it download my image.

I did not start it, because I wanted to ensure it started on reboot. Upon reboot, that’s when the user-docker would crash and halt all other processes; console was unavailable, and ssh was not available. It was only after I added the two labels (system and network) did it work.

When loading just the system label, it didn’t crash (partial success!) but it did start before network, and thus added that label AFTER I realized that the system label worked.

Ultimately, I would like for services to NOT be started under the system context.