Use Systemd Starting/Stoping Container With OS

Guide how to systemdizing a mysql docker container

Posted by vmt1991 on 18 Jun 2020
Linux-Unix

*Use system starting/stoping container with OS:

-Pull mysql image 5.7: # docker pull mysql:5.7

-Create file store enviroments value for starting container mysql: /usr/share/mysql-container.env

-Create file /etc/systemd/system/docker.mysql.service for define  new service:

-Reload new service to systemctl:

-Start containser as start service by systemctl command:

-Checking container running successful

-Use docker exec  to add process shell bash for accessing inside container:

-Connect to mysql with username/password and check database created with value in environment file: /usr/share/mysql-container.env in step 2

-Enable service for running container with OS:

-Reboot OS and checking container automatic running :