Add docker support
diff --git a/mysql/common.sls b/mysql/common.sls
index a58e163..6a91967 100644
--- a/mysql/common.sls
+++ b/mysql/common.sls
@@ -13,6 +13,13 @@
 
 {%- endif %}
 
+mysql_salt_config:
+  file.managed:
+    - name: /etc/salt/minion.d/mysql.conf
+    - template: jinja
+    - source: salt://mysql/files/salt-minion.conf
+    - mode: 600
+
 mysql_packages:
   pkg.installed:
   - names: {{ server.pkgs }}
@@ -25,17 +32,34 @@
   - source: salt://mysql/conf/my.cnf.{{ grains.os_family }}
   - mode: 644
   - template: jinja
-  - require: 
+  - require:
     - pkg: mysql_packages
-  - watch_in:
-    - service: mysql_service
 
 {%- endif %}
 
+
+{%- if not grains.get('noservices', False) %}
 mysql_service:
   service.running:
   - name: {{ server.service }}
   - enable: true
+  {%- if server.version != '5.6' %}
+  - watch:
+    - file: mysql_config
+  {%- endif %}
+  - require:
+    - file: mysql_salt_config
+{%- endif %}
+
+
+{%- if grains.get('virtual_subtype', None) == "Docker" %}
+mysql_entrypoint:
+  file.managed:
+  - name: /entrypoint.sh
+  - template: jinja
+  - source: salt://mysql/files/entrypoint.sh
+  - mode: 755
+{%- endif %}
 
 mysql_config_dir:
   file.directory:
@@ -53,7 +77,7 @@
   - user: root
   - group: root
   - makedirs: true
-  - require: 
+  - require:
     - pkg: mysql_packages
 
 /root/mysql/flags:
@@ -62,7 +86,7 @@
   - user: root
   - group: root
   - makedirs: true
-  - require: 
+  - require:
     - pkg: mysql_packages
 
 
@@ -124,7 +148,7 @@
   - source: salt://mysql/conf/automysqlbackup.conf
   - mode: 644
   - template: jinja
-  - require: 
+  - require:
     - file: mysql_backup_dirs
 
 mysql_automysqlbackup_script:
@@ -132,7 +156,7 @@
   - name: /root/mysql/scripts/automysqlbackup
   - source: salt://mysql/conf/automysqlbackup
   - mode: 755
-  - require: 
+  - require:
     - file: mysql_backup_dirs
 
 mysql_automysqlbackup_cron:
@@ -141,7 +165,7 @@
   - source: salt://mysql/conf/automysqlbackup.cron
   - mode: 755
   - template: jinja
-  - require: 
+  - require:
     - file: mysql_backup_dirs
 
 {%- endif %}
diff --git a/mysql/files/entrypoint.sh b/mysql/files/entrypoint.sh
new file mode 100644
index 0000000..64a1bc4
--- /dev/null
+++ b/mysql/files/entrypoint.sh
@@ -0,0 +1,11 @@
+{%- from "mysql/map.jinja" import server with context -%}
+#!/bin/bash -e
+
+salt-call --local --retcode-passthrough state.highstate
+service {{ server.service }} stop || true
+
+su mysql --shell=/bin/sh -c '/usr/sbin/mysqld'
+
+{#-
+vim: syntax=jinja
+-#}
diff --git a/mysql/files/salt-minion.conf b/mysql/files/salt-minion.conf
new file mode 100644
index 0000000..6b7d028
--- /dev/null
+++ b/mysql/files/salt-minion.conf
@@ -0,0 +1,11 @@
+{%- from "mysql/map.jinja" import server with context -%}
+mysql.unix_socket: /var/run/mysqld/mysqld.sock
+{%- if server.admin is defined %}
+mysql.user: '{{ server.admin.user }}'
+mysql.pass: '{{ server.admin.password }}'
+{%- else %}
+mysql.user: 'root'
+mysql.pass: ''
+{%- endif %}
+mysql.db: 'mysql'
+mysql.charset: 'utf8'
diff --git a/mysql/server.sls b/mysql/server.sls
index 96bdfa1..78da178 100644
--- a/mysql/server.sls
+++ b/mysql/server.sls
@@ -104,6 +104,7 @@
 {%- endif %}
 
 
+{%- if not grains.get('noservices', False) %}
 {%- for database_name, database in server.get('database', {}).iteritems() %}
 
 mysql_database_{{ database_name }}:
@@ -172,5 +173,6 @@
   {%- endif %}
 
 {%- endfor %}
+{%- endif %}
 
 {%- endif %}