This is a unit file for docker-compose especially for Systemd based systems. You can name it ‘docker-compose.service’ and place this file into /etc/systemd/system/ directory.
Please modify the WorkingDirectory parameter and place the absolute path of your directory where you have your docker-compose.yml file.

Run ‘systemctl daemon-reload’ after modifying the service file for the changes to take effect.

[Unit]
Description=docker compose service file
Requires=docker.service
After=docker.service

[Service]
WorkingDirectory=/srv/compose  
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/docker-compose up -d
ExecStop=/usr/bin/docker-compose down

[Install]
WantedBy=multi-user.target