Lets start off by deploying a single MySQL DB instance. For this, we’re going to use the default mysql image from docker hub. In order to deploy anything to CoreOS, you need to first create a service file. Here’s one for the MySQL that we’re going to deploy.
Description=MySQL database for wordpress
ExecStartPre=-/usr/bin/docker stop wpdb
ExecStartPre=-/usr/bin/docker rm wpdb
ExecStartPre=-/usr/bin/docker pull mysql:latest
ExecStart=/usr/bin/docker run -e MYSQL_ROOT_PASSWORD=glory86 --name wpdb -t mysql:latest
Save that file as wpdb.service. Lets examine that file. As you can see, the file is split into three distinct sections. Unit, Service and X-Fleet. The Unit section tells CoreOS, or more specifically fleet, what this service is about and what it is for. Since this one is quite simple, we only have a Description here. Continue reading