11# DockWatch
2- An application for listing out your deployed containers on a specific node.
2+ [ ![ License MIT] ( https://img.shields.io/badge/license-MIT-blue.svg )] ( ./LICENCE )
3+ [ ![ ] ( https://img.shields.io/docker/automated/mabruras/dockwatch.svg )] ( https://hub.docker.com/r/mabruras/dockwatch ' DockerHub ')
4+ [ ![ ] ( https://img.shields.io/docker/stars/mabruras/dockwatch.svg )] ( https://hub.docker.com/r/mabruras/dockwatch ' DockerHub ')
5+ [ ![ ] ( https://img.shields.io/docker/pulls/mabruras/dockwatch.svg )] ( https://hub.docker.com/r/mabruras/dockwatch ' DockerHub ')
36
4- ## Why DockWatch
5- We do all have a full CI/CD setup, so what more do we need?
7+ Application for listing deployed applications in a single- or multi-node environment.
68
7- Since we've might have enabled the possibility to deploy code from
8- every branch in each of the repositories - it's necessary to keep
9- track of what is running on all the nodes in each environment.
9+ ## What is DockWatch
10+ DockWatch is a system for accessing an overview of
11+ all deployed Docker containers in an environment.
1012
11- With the DockWatch running on each of the nodes in an environment, it's
12- possible to get an overview of all running containers on each node .
13+ By restricting which containers being visible and possible to interact with,
14+ it's easy to let the developers manage the environments on their own .
1315
14- Through the UI it will be possible to interact with specific containers,
15- like delete, restart or access logs. Main focus should be to clean
16- up earlier deployments, of feature branches that is not relevant anymore .
16+ As a contribution to a feature-branch deployment system, DockWatch will let
17+ the developers see what versions of each application, is currently deployed.
18+ It is possible to remove, restart and watch the logs of the containers .
1719
18- ~~ It is possible to configure each DockWatch to access
19- the other APIs of the other DockWatch instances.
20- This is done runtime, by adding a new Node with name,
21- API URL and other grouping tags~~
22- _ Currently not implemented, WIP_
20+ DockWatch wants to highlight the importance of developer contribution towards the
21+ application environments, by letting them take part in the deployment processes.
2322
23+ ## Overview
24+ When deploying multiple branches of each applications,
25+ it's useful to get them grouped by the application name.
2426
25- # Technology
26- DockWatch mainly consist of two components; ** API** and ** Web** .
27-
28- Both systems are bundled, where a Python Flask instance serves a React
29- frontend, as well as an API for interaction with the Docker engine.
30-
31- ~~ ̃It's not necessary to take use of the Web component for each node.
32- Because of the possibility to add other API URLs runtime~~
33-
34- ## API
35- The API is a Python Flask service for querying the docker engine,
36- on the node where it's deployed. It will return information about
37- all running containers, which image they are created of,
38- including version tags, and labels for both image and container.
39-
40- ### Web
41- The Web component is a React JS system, served as static files,
42- from the Flask server. It's responsible for presenting the API data
43- from one ~~ or multiple~~ node~~ s~~ .
27+ ![ Overview of deployments in DockWatch] ( ./files/images/dockwatch_images.png ' Images Overview ')
4428
4529
4630# Usage
@@ -52,90 +36,135 @@ always should be mounted, to actually access the local docker engine.
5236docker run -v /var/run/docker.sock:/var/run/docker.sock mabruras/dockwatch
5337```
5438
55- It's recommended to run DockWatch with the ` hidden ` -label,
56- to avoid it discovering itself, and not being able shut it down through itself.
39+ It's recommended to run DockWatch with the ` hidden ` -label, to avoid it discovering itself,
40+ and denying users interacting with it's running state through the UI.
41+ Alternatively the ` restartable ` - and ` removable ` -labels can be used.
5742Make also sure to export the ` 1609 ` -port where the application is running.
5843``` bash
5944docker run -d \
6045 -p 1609:1609 \
61- -l " dockwatch.hidden=True " \
46+ -l " dockwatch.hidden=true " \
6247 -v /var/run/docker.sock:/var/run/docker.sock \
6348 mabruras/dockwatch
6449```
6550
51+ ### Multiple Nodes
52+ To start it with synchronization across multiple nodes, the following should be a minimum.
6653
67- ## Standalone Applications
68- It is possible to deploy either of the components (API and Web) standalone,
69- even though it's recommended to always be deployed as a complete system.
70-
71-
72- ### Deploy
73- You can deploy a single instance of the API, which is
74- useful when planning to use a centralized DockWatch Web instance.
7554``` bash
76- docker build -t mabruras/dockwatch-api api
77-
7855docker run -d \
79- -p 1609:1609 \
56+ --net host \
57+ -l " dockwatch.hidden=true" \
58+ -e " DW_GROUP=dev" \
59+ -e " DW_MODE=multi" \
60+ -e " DW_SECRET=mySecret" \
8061 -v /var/run/docker.sock:/var/run/docker.sock \
81- mabruras/dockwatch-api
62+ mabruras/dockwatch
8263```
64+ ** [ !] ** Remember that ` DW_SECRET ` should be the same to all instances in the same ` DW_GROUP ` !
8365
84- If there is deployed multiple singular APIs in the environment,
85- it might be useful to only deploy a singular Web instance, without any connected API.
86- When deploying a singular Web component,
87- make note of the ` REACT_APP_API_URL ` to override the default API URL.
88- ~~ There is also possible to manually add multiple other API references through the UI.~~
89- ``` bash
90- docker build -t mabruras/dockwatch-web web
9166
92- docker run -d \
93- -p 3000:3000 \
94- -e " REACT_APP_API_URL=http://localhost:1609/api" \
95- mabruras/dockwatch-web
96- ```
97-
98- ### Environment Variables
67+ ## Environment Variables
9968Currently there isn't implemented use of a configuration file,
10069but options are available through environment variables.
101- Make sure that your deployment includes the necessary values by modifying these.
70+ Make sure that your deployment includes the necessary values by modifying these environment variables.
71+
72+ ### General
73+ | VARIABLE | EXAMPLE | DESCRIPTION | DEFAULT |
74+ | :------- | :-----: | :---------- | :-----: |
75+ | ` WRK_DIR ` | /opt/dockwatch | Directory where dockwatch is located | current directory/` . ` |
76+ | ` DW_PORT ` | 8080 | What port DownWatch is running on | 1609 |
77+ | ` DW_MODE ` | multi | ` single ` if DockWatch is a single instance, ` multi ` enables "Multiple Nodes" | single |
78+ | ` DW_LOG_THRESHOLD ` | 120 | ** Seconds** to hold each log stream open | 300 |
79+
80+ ** [ !] ** Be careful with ` DW_LOG_THRESHOLD ` .
81+ This value tells when to close a log stream, after accessing
82+ a detailed page for a container, where the log is streamed.
83+ Since closing the page will not close the open log stream server side,
84+ there is implemented a timeout for the stream.
85+ Hopefully this will be changed with a better solution down the road.
86+
87+ ### Multiple Nodes
88+ Some environment variables does only make sense to use in Multi mode,
89+ due the configuration of synchronization is superfluous when not using it.
90+
91+ | VARIABLE | EXAMPLE | DESCRIPTION | DEFAULT |
92+ | :------- | :-----: | :---------- | :-----: |
93+ | ` DW_GROUP ` | Development | Grouping of DockWatch instances, to pick up broadcasts from only within the group | dw_default |
94+ | ` DW_SECRET ` | 53cr37-p455w0rd | Broadcast message encryption, must be equal within ` DW_GROUP ` | |
95+ | ` DW_BROADCAST_PORT ` | 12345 | Select port to send/receive broadcast messages through | 11609 |
96+ | ` DW_BROADCAST_INTERVAL ` | 5 | Time delay in minutes between broadcasts | 30 |
97+ | ` DW_NET_MASK ` | 255.255.0.0 | Network mask for your subnet, is used to determine broadcast address | 255.255.255.0 |
98+
99+
100+ ## Internal Labels
101+ Internal labels are those who DockWatch uses for execute extra,
102+ custom or special logic, when detecting on a container.
102103
103- | VARIABLE | EXAMPLE | DESCRIPTION |
104- | :------: | :-----: | :---------: |
105- | DW_PORT | 8080 | What port DownWatch is running on (_ default: 1609_ ) |
106- | REACT_APP_API_URL | http://localhost:1609/api | URL for where to access the DockWatch API |
107- | REACT_APP_URL_LBL | app.url | What label referring to the applications URL (_ default: container.url_ ) |
104+ | LABEL | DESCRIPTION | VALUE |
105+ | :---: | :---------: | :---: |
106+ | dockwatch.hidden | Marks the container as hidden, and unavailable through DockWatch Web | ` true ` or ` false ` |
107+ | dockwatch.restartable | Enable or disable the posibility to ** restart** the container | ` true ` or ` false ` |
108+ | dockwatch.removable | Enable or disable the possibility to ** remove/delete** the container | ` true ` or ` false ` |
109+ | dockwatch.url | URL for accessing the application running in the container | _ custom_ |
108110
111+ ### Hidden
112+ It's not everything that should be exposed to the users, that's why a container could be hidden from DockWatch.
113+ It's recommended that services like DockWatch should be hidden by default.
109114
110- ### Internal Labels
111- Internal labels are those who DockWatch uses for execute extra,
112- custom or special logic, when detecting on a container .
115+ ### Restartable
116+ Users are able to restart containers with this flag.
117+ Do not use this label on containers that should not be restarted by the users .
113118
114- #### Hidden containers
115- It's not everything that should be exposed to the users,
116- that's why a container can be hidden from DockWatch.
117- Services like DockWatch should by default be hidden,
118- and could be labeled with ` dockwatch.hidden=true ` to achieve this.
119+ ### Removable
120+ Users are able to remove containers with this flag.
121+ The action of removing a container is not revertible - don't let users remove your critical containers.
119122
123+ ### Container URL
124+ Enabled link to the deployed version of the application.
125+ Recommended to be included, for usability and accessibility for the developer and/or users.
120126
121- ### Docker Compose
122- Instead of running each and every one of the components manually,
123- there is created Docker Compose files for handling this.
124- These files already are preconfigured with the recommended
125- labels and environment variables.
126127
127- ``` bash
128- docker-compose -f files/docker-compose.yml build
129- docker-compose -f files/docker-compose.yml up -d
130- ```
128+ # Technology
129+ DockWatch mainly consist of two components; ** API** and ** Web** .
131130
132- ##### Override default environment variable
133- It's important to notice that the docker-compose file contains a
134- default to what API the Web instance is connecting towards; localhost.
135- To override the APIs default URL, you can set the ` DOCK_WATCH_API `
136- environment variable being the address to the node running the API.
131+ Both systems are bundled, where a Python Flask backend serves a React
132+ frontend, as well as an API for interaction with the Docker engine.
137133
138- ``` bash
139- export DOCKWATCH_API=" http://api.example.com"
140- docker-compose -f files/docker-compose.yml up -d
141- ```
134+ ## API
135+ The API is a Python Flask service for querying the Docker engine,
136+ on the node where it's deployed, as well as other nodes - if available.
137+ It will return information about all running containers,
138+ which image they are created of (including version tags),
139+ and labels for both image and container, for each node available.
140+
141+ ## Web
142+ The Web component is created on the React JS framework, served as static files,
143+ from the Flask server. It's responsible for presenting the API data from each node.
144+
145+
146+ # Multiple Nodes
147+ By running DockWatch with ` --net=host ` , it is able to
148+ automatically synchronize between instances within the same subnet.
149+
150+ They will share their own IP address, along with all other known IP addresses
151+ from earlier broadcasts. Each broadcast will reach out to the other instances
152+ to increase the possibility of each node knowing about each other.
153+
154+ When a user interacts with a container, the instance contacted will reach
155+ out to all known DockWatch instances to perform the same action on each node.
156+
157+ It could be hard to read logs on multiple instances, so DockWatch
158+ solves this by letting the user select each node separately.
159+
160+ DockWatch connects to other instances by broadcasting it's own position,
161+ triggering all listening instances to do the same.
162+ Each broadcast received is used to update its own configuration to keep
163+ track of where each instance is running.
164+
165+ By regularly broadcasting the positions, it increases the chance of detecting
166+ each other and keep up to date each API reference.
167+
168+ When interacting with a instance, it will start a sequence of similar API
169+ calls to the rest of the instances. This lets the user known the status of
170+ each instance.
0 commit comments