This commit is contained in:
parent
0ac32cb47c
commit
6a581eae0a
2 changed files with 119 additions and 90 deletions
90
CONTAINER.md
Normal file
90
CONTAINER.md
Normal file
|
@ -0,0 +1,90 @@
|
|||
# Container
|
||||
|
||||
Use `podman` or `docker`:
|
||||
|
||||
```sh
|
||||
podman run tiptop:5000/sms_handler
|
||||
```
|
||||
|
||||
**Note**: the container is not published publicly yet!
|
||||
|
||||
Pass parameters like this:
|
||||
|
||||
```sh
|
||||
podman run -e SMS_HANDLER_MAIL_SERVER_PORT=8025 -e SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com SMS_HANDLER_MAIL_TO=snoopy@peanuts.com tiptop:5000/sms_handler
|
||||
```
|
||||
|
||||
## Container as a systemd service
|
||||
|
||||
Systemd can "orchestrate" containers easily thanks to podman.
|
||||
|
||||
### Rootless (as regular user)
|
||||
|
||||
For a rootless container, create a file in `.config/containers/systemd/sms-handler.container`:
|
||||
|
||||
```systemd
|
||||
[Container]
|
||||
ContainerName=sms-handler
|
||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
||||
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
||||
Image=tiptop:5000/sms_handler
|
||||
Network=podman
|
||||
PublishPort=8025:8025
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
|
||||
Request systemd to reload configuration, creating the service for this container:
|
||||
|
||||
```sh
|
||||
systemctl --user daemon-reload
|
||||
```
|
||||
|
||||
Start the container as a service:
|
||||
|
||||
```sh
|
||||
systemctl start sms-handler.service
|
||||
```
|
||||
|
||||
To start rootless containers at boot time, without the need for the user (snoopy) to log in:
|
||||
|
||||
```sh
|
||||
sudo loginctl enable-linger snoopy
|
||||
```
|
||||
|
||||
### Rootful (as root)
|
||||
|
||||
For a rootless container, create a file in `/etc/containers/systemd/sms-handler.container`:
|
||||
|
||||
```systemd
|
||||
[Container]
|
||||
ContainerName=sms-handler
|
||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
||||
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
||||
Image=tiptop:5000/sms_handler
|
||||
Network=podman
|
||||
PublishPort=8025:8025
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
|
||||
Request systemd to reload configuration, creating the service for this container:
|
||||
|
||||
```sh
|
||||
sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
Start the container as a service:
|
||||
|
||||
```sh
|
||||
sudo systemctl start sms-handler.service
|
||||
```
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue