start docker as systemd on centos7/rhel7

Here is an example how you can start a docker container as a service. After reboot this docker instance will be started.
Create a service file like this: 

[Unit]

Description=Redis Docker Container 

After=docker.service

Requires=docker.service

 

[Service]

User=chris

RemainAfterExit=true

ExecStart=/bin/docker run -d –name redis redis

ExecStop=/bin/docker stop -t 2 redis 

ExecStopPost=/bin/docker rm -f redis

 

[Install]

WantedBy=multi-user.target

/etc/systemd/system/redis.service

test it with the following command:

systemctl start redis

stop it with: systemctl stop redis

make this permanent with systemctl enable redis