Skip to content

Commit 74f099d

Browse files
authored
docs: add docker example (#4)
This commit adds an example on how tmux-notify can be used within a docker container.
1 parent 88835d1 commit 74f099d

File tree

6 files changed

+66
-0
lines changed

6 files changed

+66
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ Tmux plugin to notify you when processes are complete.
1818
- [Usage](#usage)
1919
- [Pre-requisites](#pre-requisites)
2020
- [Configuration](#configuration)
21+
- [Enable verbose notification](#enable-verbose-notification)
22+
- [Enable telegram channel notifications](#enable-telegram-channel-notifications)
23+
- [Change monitor update period](#change-monitor-update-period)
24+
- [Add additional shell suffixes](#add-additional-shell-suffixes)
2125
- [How does it work](#how-does-it-work)
26+
- [Other use cases](#other-use-cases)
27+
- [Use inside a docker container](#use-inside-a-docker-container)
2228
- [Contributing](#contributing)
2329
- [References](#references)
2430

@@ -108,6 +114,12 @@ Feel free to open [a pull](https://github.com/rickstaa/tmux-notify/pulls) reques
108114

109115
A naive approach. Checks if pane content ends with the bash prompt suffixes mentioned above every 10 seconds.
110116

117+
## Other use cases
118+
119+
### Use inside a docker container
120+
121+
Because tmux-notify uses [libnotify](https://gitlab.gnome.org/GNOME/libnotify) to send notifications, it needs access to the host's D-Bus socket. An excellent guide on how to do this can be found [here](https://github.com/mviereck/x11docker/wiki/How-to-connect-container-to-DBus-from-host#dbus-user-session-daemon). You can also check out the [examples/docker](examples/docker/README.md) folder for an example.
122+
111123
## Contributing
112124

113125
Feel free to open an issue if you have ideas on how to make this GitHub action better or if you want to report a bug! All contributions are welcome. :rocket: Please consult the [contribution guidelines](CONTRIBUTING.md) for more information.

examples/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Examples
2+
3+
This folder contains several examples on how to use tmux-notify in different scenarios:
4+
5+
- ``docker``: A simple example on how to make tmux-notify work inside a docker container.

examples/docker/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# A small Dockerfile to build a container in which tmux-notify can be tested.
2+
FROM ubuntu:latest
3+
4+
# Install required packages.
5+
RUN apt-get update
6+
RUN apt-get upgrade -y
7+
RUN apt-get install -y \
8+
libnotify-bin \
9+
dbus \
10+
tmux \
11+
git

examples/docker/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Docker example
2+
3+
This example shows how to make tmux-notify work inside a docker container. You can test it out by executing the following inside your terminal:
4+
5+
```bash
6+
bash docker_test.sh
7+
```
8+
9+
This command will open a Tmux session inside a docker container, and if you have installed [tmp](https://github.com/tmux-plugins/tpm) and [tmux-notify](https://github.com/rickstaa/tmux-notify), on your host machine you should be able to use [tmux-notify](https://github.com/rickstaa/tmux-notify) as usual. For more information on how this works, see [this guide](https://github.com/mviereck/x11docker/wiki/How-to-connect-container-to-DBus-from-host#dbus-user-session-daemon).

examples/docker/docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: "3"
2+
services:
3+
app:
4+
image: tmux-notify-test:latest
5+
build: .
6+
environment:
7+
- DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus # Replace with your user id.
8+
security_opt:
9+
- apparmor:unconfined
10+
volumes:
11+
- /run/user/1000/bus:/run/user/1000/bus # Replace with your user id.
12+
- /etc/group:/etc/group:ro
13+
- /etc/passwd:/etc/passwd:ro
14+
- $HOME/.tmux:$HOME/.tmux # Your tmux folder.
15+
- $HOME/.tmux.conf:$HOME/.tmux.conf # Your tmux config.
16+
- $HOME/.tmux.conf.local:$HOME/.tmux.conf.local # Your tmux local config.
17+
user: 1000:1000 # Replace with your user / group id.

examples/docker/docker_test.bash

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Command line example with all parameters needed to run tmux-notify inside a docker container.
2+
docker build -t tmux-notify-docker-test:latest .
3+
docker run -e DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \
4+
-v /run/user/1000/bus:/run/user/1000/bus \
5+
-v /etc/group:/etc/group:ro \
6+
-v /etc/passwd:/etc/passwd:ro \
7+
-v $HOME/.tmux:$HOME/.tmux \
8+
-v $HOME/.tmux.conf:$HOME/.tmux.conf \
9+
-v $HOME/.tmux.conf.local:$HOME/.tmux.conf.local \
10+
--security-opt apparmor=unconfined \
11+
-u $(id -u):$(id -g) \
12+
-it tmux-notify-docker-test:latest tmux

0 commit comments

Comments
 (0)