-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make a Systemd Unit for docker-compose? #4266
Comments
Hi! I unfortunately do not have the |
thanks anyway. |
@gunboe I can verify that this is correct. When docker-compose is run from the command line it still spawns to processes when looking at |
@gunboe I would try using this instead instead of Type simple
|
Here is what I am using ...
|
What did the trick in my case is setting the user
UPDATE: I had to enable the service too |
Place following content to the
Place you
See updates and other systemd tricks for docker here |
For anyone coming here like myself wondering about the correct approach, you're better off using |
@mosquito Mad props (That's what the cool kids say, isn't it) for that modular script 👍 I think you might want to edit it to change the working directory, as some peeps might just copy-paste it to discover that it's writing into |
@hickscorp I think you should change working directory in your |
@mosquito Yep that's also an option. On another note: I'm trying to get it to work, but it doesn't for me. Whether I EDIT: I know the file has to be renamed, I'm trying to point out that it should be clearer in the proposed solution ;) |
@hickscorp so... I add the header to the comment. 😅 |
@mosquito Shouldn't you use |
@TheDauthi I would personally opt to leave it in in the event that there was an issue with either the service or the docker commands at launch, especially with |
The best way I have setup it:
Enjoy yourself! |
I am googled this post for Habor. So lucky! |
I've tried to make a service Unit to initialize some Docker images by docker-compose in Systemd. I have saw somes examples at Internet, but the only works, there is one trap...
With these harbor.service file:
[Unit]
Description=Servico de manutencao do Harbor
After=network.target docker.service
[Service]
Type=simple
WorkingDirectory=/opt//harbor
ExecStart=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml down
#Restart=always
[Install]
WantedBy=multi-user.target
I start de Unit and after I receive this status:
# systemctl start harbor
# systemctl status harbor
● harbor.service - Servico de manutencao do Harbor
Loaded: loaded (/etc/systemd/system/harbor.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2016-12-19 20:09:44 BRST; 16min ago
Main PID: 2028 (docker-compose)
Memory: 34.3M
CGroup: /system.slice/harbor.service
├─2028 /usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up
└─2029 /usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up
Everything is OK, all Dockers container running. I can stop the harbor service without any problem. But now I have two docker-compose process.
Is there normal? Could I have problems in Future with these two process? How to make service Unit file better for docker-compose?
Thanks.
The text was updated successfully, but these errors were encountered: