Last active
September 21, 2021 19:34
-
-
Save BenHall/b31e7778dbc4ed612dbcf40acccbf1df to your computer and use it in GitHub Desktop.
Docker Systemd Unit File
This file contains 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 characters
[Unit] | |
Description=PostgreSQL container | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=on-failure | |
RestartSec=10 | |
ExecStartPre=-/usr/bin/docker stop postgres | |
ExecStartPre=-/usr/bin/docker rm postgres | |
ExecStart=/usr/bin/docker run --name postgres \ | |
--volume /srv/db/postgres:/var/lib/pgsql/data \ | |
kiasaki/alpine-postgres | |
ExecStop=/usr/bin/docker stop postgres | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@f4th4n, the output you show says
Started PostgreSQL container
, so I think you're fine. TheExecStartPre
lines start with-
, which means to ignore errors. Apparently it's still printing those errors out. But thoseExecStartPre
lines are just stopping any existing Docker instances, to ensure that the Docker instance will start up correctly. You should be able to ignore the error messages in the logs.I don't think you can add redirection to any of the
Exec
parameters. Otherwise I'd suggest adding>/dev/null 2>&1
to theExecStartPre
lines. Not sure if it's worth adding that; if so, it'd look like this:But I'm honestly not even sure it's necessary to have those lines in there at all.