1

I'm trying to configure docker exec with systemd service, but it always fail.

  • The command is working fine when executed directly in the terminal (ssh).

Q: Is that possible to run that way or I need to use inside a bash script (.sh)?


/etc/systemd/system/laravel.service

[Unit]
Description=Laravel Queue
After=docker.service
Requires=docker.service

[Service]
Type=simple
ExecStart="/usr/bin/docker exec -it my_docker /usr/bin/php artisan queue:work --env=production --tries 2 --timeout 60"
User=ubuntu
Group=ubuntu
KillMode=process
Restart=always

[Install]
WantedBy=multi-user.target

sudo service vetspay status

jan 05 03:04:39 legolas systemd[1]: Started Laravel Queue.
jan 05 03:04:39 legolas systemd[1]: laravel.service: Main process exited, code=exited, status=216/GROUP
jan 05 03:04:39 legolas systemd[1]: laravel.service: Unit entered failed state.
jan 05 03:04:39 legolas systemd[1]: laravel.service: Failed with result 'exit-code'.
Luciano Nascimento
  • 2,600
  • 2
  • 44
  • 80

2 Answers2

1

The error (the input device is not...) is caused by : -it in this line ExecStart="/usr/bin/docker exec -it my_docker /usr/bin/php artisan queue:work --env=production --tries 2 --timeout 60" User=ubuntu , remove it, it is not necessary when docker exec is in bash file

0

I tested the command inside a script and got the error: the input device is not a TTY

Basically I cannot use the command with -t because those are non interactive. Removing it now it's working properly!


Where I found the answer:

the input device is not a TTY

Luciano Nascimento
  • 2,600
  • 2
  • 44
  • 80
  • 1
    There are more corner cases involved in running docker from systemd than this answer addresses. Consider using [`systemd-docker`](https://github.com/ibuildthecloud/systemd-docker) -- this provides SD_NOTIFY socket integration, bridges the differences in cgroup conventions, handles propagating logs through, and otherwise resolves the issue more comprehensively. – Charles Duffy Jan 05 '18 at 17:41