runcmd is executed at the run level before the docker service is started.
Reference: When using runcmd, RancherOS will wait for all commands to complete before starting Docker
[rancher@ip-172-31-8-65 ~]$ sudo system-docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
61cbe4279219 rancher/os-console:v0.8.0 "/usr/bin/ros entrypo" 3 weeks ago Up 3 weeks console
ef4b6a51a53b rancher/os-docker:1.12.6 "ros user-docker" 3 weeks ago Up 3 weeks docker
...
To run docker commands on system bootup, can create /etc/rc.local file, or other run level startup scripts
This is a good guide: https://docs.rancher.com/os/configuration/running-commands/
The best way to do this is to define a rancher.services in the #cloud-init as suggested by @imikushin
just two month ago (as I’m writing this comment), rancher also introduced a new parameter awslocal to the –advertise-address parameter, hence you could start rancher in HA mode on startup, through defining rancher.services in #cloud-init
e.g.
#cloud-config
mounts:
-
- /dev/vdb
- /mnt
- ext4
- ""
ssh_authorized_keys:
- $key
rancher:
services:
rancher-server:
image: rancher/server:stable
restart: unless-stopped
command:
- --db-host
- $mariadb_ip
- --db-user
- $cattle_user
- --db-pass
- $cattle_password
- --db-name
- $cattle_db
- --advertise-address
- awslocal
ports:
- 8080:8080
- 9345:9345
This is the change that introduced awslocal https://github.com/rancher/rancher/commit/9fb7750a1a9e83e8a49f58a92020f8b42941b5a5