-
-
Save josefsalyer/9003339e17bb5ba392feb16e6d59242a to your computer and use it in GitHub Desktop.
Revisions
-
mosquito revised this gist
May 19, 2017 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -73,4 +73,6 @@ ExecStart=/bin/docker ps -af status=exited [Install] WantedBy=multi-user.target ``` run `systemctl enable docker-cleanup.timer` for enabling the timer -
mosquito revised this gist
May 19, 2017 . 1 changed file with 37 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,3 +37,40 @@ Place your `docker-compose.yml` into `/etc/docker/compose/myservice` and call systemctl start docker-compose@myservice ``` Docker cleanup timer with system ================================ Create `/etc/systemd/system/docker-cleanup.timer` with this content: ```ini [Unit] Description=Docker cleanup timer [Timer] OnUnitInactiveSec=12h [Install] WantedBy=timers.target ``` And service file `/etc/systemd/system/docker-cleanup.service`: ```ini [Unit] Description=Docker cleanup Requires=docker.service After=docker.service [Service] Type=oneshot WorkingDirectory=/tmp User=root Group=root ExecStartPre=-/bin/bash -c 'docker ps -aqf status=exited | xargs docker rm -v' ExecStartPre=-/bin/bash -c 'docker images -qf dangling=true | xargs docker rmi -f' ExecStart=/bin/docker ps -af status=exited [Install] WantedBy=multi-user.target ``` -
mosquito revised this gist
May 19, 2017 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ Docker compose as a systemd unit ================================ Create file `/etc/systemd/system/[email protected]` ```ini @@ -28,8 +31,9 @@ ExecStop=/usr/bin/docker-compose down -v WantedBy=multi-user.target ``` Place your `docker-compose.yml` into `/etc/docker/compose/myservice` and call ``` systemctl start docker-compose@myservice ``` -
mosquito revised this gist
May 19, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ Create file `/etc/systemd/system/[email protected]` ```ini [Unit] Description=%i service with docker compose Requires=docker.service -
mosquito revised this gist
May 19, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ Create file `/etc/systemd/system/[email protected]` ``` [Unit] -
mosquito revised this gist
May 19, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ Create file `[email protected]` ``` [Unit] Description=%i service with docker compose -
mosquito revised this gist
May 19, 2017 . No changes.There are no files selected for viewing
-
mosquito revised this gist
May 19, 2017 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,9 +26,7 @@ ExecStop=/usr/bin/docker-compose down -v WantedBy=multi-user.target ``` Place you `docker-compose.yml` into `/etc/docker/compose/myservice` and call ``` systemctl start docker-compose@myservice -
mosquito created this gist
May 19, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ ``` [Unit] Description=%i service with docker compose Requires=docker.service After=docker.service [Service] Restart=always WorkingDirectory=/etc/docker/compose/%i # Remove old containers, images and volumes ExecStartPre=/usr/bin/docker-compose down -v ExecStartPre=/usr/bin/docker-compose rm -fv ExecStartPre=-/bin/bash -c 'docker volume ls -qf "name=%i_" | xargs docker volume rm' ExecStartPre=-/bin/bash -c 'docker network ls -qf "name=%i_" | xargs docker network rm' ExecStartPre=-/bin/bash -c 'docker ps -aqf "name=%i_*" | xargs docker rm' # Compose up ExecStart=/usr/bin/docker-compose up # Compose down, remove containers and volumes ExecStop=/usr/bin/docker-compose down -v [Install] WantedBy=multi-user.target ``` Place you `docker-compose.yml` into `/etc/docker/compose/myservice` and call ``` systemctl start docker-compose@myservice ```