Skip to content

Commit cdb6bfb

Browse files
authored
Merge pull request #1777 from altsalt/patch-1
Add documentation about password protecting Docker
2 parents dae111e + df15da7 commit cdb6bfb

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

docs/docker.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,79 @@ You can also include Glances container in you own `docker-compose.yml`. Here's a
7373
labels:
7474
- "traefik.port=61208"
7575
- "traefik.frontend.rule=Host:glances.docker.localhost"
76+
77+
How to protect your Dockerized server (or Web server) with a login/password ?
78+
------------------------------------------------------------------
79+
80+
Below are two methods for setting up a login/password to protect Glances running inside a Docker container.
81+
82+
Option 1
83+
^^^^^^^^
84+
85+
You can enter the running container by entering this command (replacing ``glances_docker`` with the name of your container):
86+
87+
.. code-block:: console
88+
89+
docker exec -it glances_docker sh
90+
91+
and generate the password file (the default login is ``glances``, add the ``--username`` flag if you would like to change it):
92+
93+
.. code-block:: console
94+
95+
glances -s --password
96+
97+
which will prompt you to answer the following questions:
98+
99+
.. code-block:: console
100+
Define the Glances server password (glances username):
101+
Password (confirm):
102+
Do you want to save the password? [Yes/No]: Yes
103+
104+
after which you will need to kill the process by entering ``CTRL+C`` (potentially twice), before leaving the container:
105+
106+
.. code-block:: console
107+
^C^C
108+
exit
109+
110+
You will then need to copy the password file to your host machine:
111+
112+
.. code-block:: console
113+
docker cp glances_docker:/root/.config/glances/glances.pwd ./secrets/glances_password
114+
115+
and make it visible to your container by adding it to ``docker-compose.yml`` as a ``secret``:
116+
117+
.. code-block:: yaml
118+
version: '3'
119+
120+
services:
121+
glances:
122+
image: nicolargo/glances:latest
123+
restart: always
124+
environment:
125+
- GLANCES_OPT="-w --password"
126+
volumes:
127+
- /var/run/docker.sock:/var/run/docker.sock:ro
128+
pid: host
129+
secrets:
130+
- source: glances_password
131+
target: /root/.config/glances/glances.pwd
132+
133+
secrets:
134+
glances_password:
135+
file: ./secrets/glances_password
136+
137+
Option 2
138+
^^^^^^^^
139+
140+
You can add a ``[passwords]`` block to the Glances configuration file as mentioned elsewhere in the documentation:
141+
142+
.. code-block:: ini
143+
144+
[passwords]
145+
# Define the passwords list
146+
# Syntax: host=password
147+
# Where: host is the hostname
148+
# password is the clear password
149+
# Additionally (and optionally) a default password could be defined
150+
localhost=mylocalhostpassword
151+
default=mydefaultpassword

0 commit comments

Comments
 (0)