File size: 43,309 Bytes
66b3b8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582


<!DOCTYPE html>

<html lang="en" data-content_root="./">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>Container Deployment &#8212; pgAdmin 4 8.6 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
    <link rel="stylesheet" type="text/css" href="_static/style.css?v=d36593c3" />
    
    <script src="_static/documentation_options.js?v=d4c83366"></script>
    <script src="_static/doctools.js?v=9a2dae69"></script>
    <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <script src="_static/sidebar.js"></script>
    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Login Page" href="login.html" />
    <link rel="prev" title="Server Deployment" href="server_deployment.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"

             accesskey="I">index</a></li>
        <li class="right" >
          <a href="login.html" title="Login Page"

             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="server_deployment.html" title="Server Deployment"

             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">pgAdmin 4 8.6 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="getting_started.html" >Getting Started</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="deployment.html" accesskey="U">Deployment</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Container Deployment</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="container-deployment">
<span id="id1"></span><h1><span class="target" id="index-0"></span>Container Deployment<a class="headerlink" href="#container-deployment" title="Link to this heading"></a></h1>
<p>pgAdmin can be deployed in a container using the image at:</p>
<blockquote>
<div><p><a class="reference external" href="https://hub.docker.com/r/dpage/pgadmin4/">https://hub.docker.com/r/dpage/pgadmin4/</a></p>
</div></blockquote>
<p>There are various tags that you can select from to get the version of pgAdmin
that you want, using a command such as this if you’re using Docker:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>pull<span class="w"> </span>dpage/pgadmin4:&lt;tag<span class="w"> </span>name&gt;
</pre></div>
</div>
<p>where <em>&lt;tag name&gt;</em> is one of the following:</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 20.0%" />
<col style="width: 80.0%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Tag name</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>latest</p></td>
<td><p>The most recent release.</p></td>
</tr>
<tr class="row-odd"><td><p>8.4</p></td>
<td><p>A specific version (8.4 in this case).</p></td>
</tr>
<tr class="row-even"><td><p>8</p></td>
<td><p>the latest release of a specific major version (major version 8 in this case).</p></td>
</tr>
<tr class="row-odd"><td><p>snapshot</p></td>
<td><p>The latest nightly test build.</p></td>
</tr>
</tbody>
</table>
<section id="postgresql-utilities">
<h2>PostgreSQL Utilities<a class="headerlink" href="#postgresql-utilities" title="Link to this heading"></a></h2>
<p>The PostgreSQL utilities <em>pg_dump</em>, <em>pg_dumpall</em>, <em>pg_restore</em> and <em>psql</em> are
included in the container to allow backups to be created and restored and other
maintenance functions to be executed. Multiple versions are included in the
following directories to allow use with different versions of the database
server:</p>
<ul class="simple">
<li><p>PostgreSQL 12: <em>/usr/local/pgsql-12</em></p></li>
<li><p>PostgreSQL 13: <em>/usr/local/pgsql-13</em></p></li>
<li><p>PostgreSQL 14: <em>/usr/local/pgsql-14</em></p></li>
<li><p>PostgreSQL 15: <em>/usr/local/pgsql-15</em></p></li>
<li><p>PostgreSQL 16: <em>/usr/local/pgsql-16</em></p></li>
</ul>
<p>The default binary paths set in the container are as follows:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nv">DEFAULT_BINARY_PATHS</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">{</span>
<span class="w">    </span><span class="s1">&#39;pg-16&#39;</span>:<span class="w"> </span><span class="s1">&#39;/usr/local/pgsql-16&#39;</span>,
<span class="w">    </span><span class="s1">&#39;pg-15&#39;</span>:<span class="w"> </span><span class="s1">&#39;/usr/local/pgsql-15&#39;</span>,
<span class="w">    </span><span class="s1">&#39;pg-14&#39;</span>:<span class="w"> </span><span class="s1">&#39;/usr/local/pgsql-14&#39;</span>,
<span class="w">    </span><span class="s1">&#39;pg-13&#39;</span>:<span class="w"> </span><span class="s1">&#39;/usr/local/pgsql-13&#39;</span>,
<span class="w">    </span><span class="s1">&#39;pg-12&#39;</span>:<span class="w"> </span><span class="s1">&#39;/usr/local/pgsql-12&#39;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>this may be changed in the <a class="reference internal" href="preferences.html#preferences"><span class="std std-ref">Preferences Dialog</span></a>.</p>
</section>
<section id="environment-variables">
<h2>Environment Variables<a class="headerlink" href="#environment-variables" title="Link to this heading"></a></h2>
<p>The container will accept the following variables at startup:</p>
<p><strong>PGADMIN_DEFAULT_EMAIL</strong></p>
<p>This is the email address used when setting up the initial administrator account
to login to pgAdmin. This variable is required and must be set at launch time.</p>
<p><strong>PGADMIN_DEFAULT_PASSWORD</strong></p>
<p>This is the password used when setting up the initial administrator account to
login to pgAdmin. This variable is required and must be set at launch time.</p>
<p><strong>PGADMIN_DEFAULT_PASSWORD_FILE</strong></p>
<p>This is the password used when setting up the initial administrator account to
login to pgAdmin. This value should be set to <em>docker secret</em> in order to set
the password. This variable is supported in docker swarm environment or while creating
container with docker compose. PGADMIN_DEFAULT_PASSWORD or PGADMIN_DEFAULT_PASSWORD_FILE
variable is required and must be set at launch time.</p>
<p><strong>PGADMIN_DISABLE_POSTFIX</strong></p>
<p><em>Default: &lt;null&gt;</em></p>
<p>If left unset, a Postfix server will be started to deliver password reset
emails.</p>
<p>If set to any value, the Postfix server will not be started, and pgAdmin will
need to be configured to use an external mail server using the <em>PGADMIN_CONFIG_</em>
options below.</p>
<p>This option is useful if you’re running in an environment that prevents the use
of sudo to start Postfix, or if you wish to use an external mail server.</p>
<p><strong>PGADMIN_ENABLE_TLS</strong></p>
<p><em>Default: &lt;null&gt;</em></p>
<p>If left un-set, the container will listen on port 80 for connections in plain
text. If set to any value, the container will listen on port 443 for TLS
connections.</p>
<p>When TLS is enabled, a certificate and key must be provided. Typically these
should be stored on the host file system and mounted from the container. The
expected paths are /certs/server.cert and /certs/server.key</p>
<p><strong>PGADMIN_LISTEN_ADDRESS</strong></p>
<p><em>Default: [::]</em></p>
<p>Specify the local address that the servers listens on. The default should work
for most users - in IPv4-only environments, this may need to be set to
0.0.0.0.</p>
<p><strong>PGADMIN_LISTEN_PORT</strong></p>
<p><em>Default: 80 or 443 (if TLS is enabled)</em></p>
<p>Allows the port that the server listens on to be set to a specific value rather
than using the default.</p>
<p><strong>PGADMIN_SERVER_JSON_FILE</strong></p>
<p><em>Default: /pgadmin4/servers.json</em></p>
<p>Override the default file path for the server definition list. See the
/pgadmin4/servers.json mapped file below for more information. See the format
of the <a class="reference external" href="https://www.pgadmin.org/docs/pgadmin4/latest/import_export_servers.html#json-format">Servers JSON file</a>.</p>
<p><strong>PGADMIN_PREFERENCES_JSON_FILE</strong></p>
<p><em>Default: /pgadmin4/preferences.json</em></p>
<p>Override the default file path for the preferences customization at the container creation. See the
/pgadmin4/preferences.json mapped file below for more information. See the format
of the <a class="reference external" href="https://www.pgadmin.org/docs/pgadmin4/latest/preferences.html#json-format">Preferences JSON file</a>.</p>
<p><strong>GUNICORN_ACCESS_LOGFILE</strong></p>
<p><em>Default: -</em> (stdout)</p>
<p>Specify an output file in which to store the Gunicorn access logs, instead of
sending them to stdout.</p>
<p><strong>GUNICORN_LIMIT_REQUEST_LINE</strong></p>
<p><em>Default: 8190</em></p>
<p>Set the maximum size of HTTP request line in bytes. By default the pgAdmin
container uses the maximum limited size offered by Gunicorn as some requests
can be quite large. In exceptional cases this value can be set to 0 (zero) to
specify “unlimited”, however this poses a potential denial of service hazard.</p>
<p><strong>GUNICORN_THREADS</strong></p>
<p><em>Default: 25</em></p>
<p>Adjust the number of threads the Gunicorn server uses to handle incoming
requests. This should typically be left as-is, except in highly loaded systems
where it may be increased.</p>
<p><strong>PGADMIN_CONFIG_*</strong></p>
<p>This is a variable prefix that can be used to override any of the configuration
options in pgAdmin’s <em>config.py</em> file. Add the <em>PGADMIN_CONFIG_</em> prefix to any
variable name from <em>config.py</em> and give the value in the format ‘string value’
for strings, True/False for booleans or 123 for numbers. See below for an
example.</p>
<p>Settings are written to <em>/pgadmin4/config_distro.py</em> within the container, which
is read after <em>/pgadmin4/config.py</em> and before <em>/pgadmin4/config_local.py</em>.
Any settings given will therefore override anything in config.py, but can be
overridden by settings in config_local.py.</p>
<p>Settings are only written to <em>/pgadmin4/config_distro.py</em> once, typically on
first launch of the container. If <em>/pgadmin4/config_distro.py</em> contains one or
more lines, then no changes are made; for example, if the container instance is
restarted, or <em>/pgadmin4/config_distro.py</em> is mapped to a file on persistent
storage (not recommended - use <em>/pgadmin4/config_local.py</em> instead)!</p>
<p>See <a class="reference internal" href="config_py.html#config-py"><span class="std std-ref">The config.py File</span></a> for more information on the available configuration settings.</p>
</section>
<section id="mapped-files-and-directories">
<h2>Mapped Files and Directories<a class="headerlink" href="#mapped-files-and-directories" title="Link to this heading"></a></h2>
<p>The following files or directories can be mapped from the container onto the
host machine to allow configuration to be customised and shared between
instances.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Warning: pgAdmin runs as the <em>pgadmin</em> user (UID: 5050) in the
<em>pgadmin</em> group (GID: 5050) in the container. You must ensure that all files
are readable, and where necessary (e.g. the working/session directory)
writeable for this user on the host machine. For example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>chown<span class="w"> </span>-R<span class="w"> </span><span class="m">5050</span>:5050<span class="w"> </span>&lt;host_directory&gt;
</pre></div>
</div>
<p>On some filesystems that do not support extended attributes, it may not be
possible to run pgAdmin without specifying a value for <em>PGADMIN_LISTEN_PORT</em>
that is greater than 1024. In such cases, specify an alternate port when
launching the container by adding the environment variable, for example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_LISTEN_PORT=5050&#39;</span>
</pre></div>
</div>
<p>Don’t forget to adjust any host-container port mapping accordingly.</p>
</div>
<p><strong>/var/lib/pgadmin</strong></p>
<p>This is the working directory in which pgAdmin stores session data, user files,
configuration files, and it’s configuration database. Mapping this directory
onto the host machine gives you an easy way to maintain configuration between
invocations of the container.</p>
<p><strong>/pgadmin4/config_local.py</strong></p>
<p>This file can be used to override configuration settings in pgAdmin. Settings
found in config.py can be overridden with deployment specific values if
required. Settings in config_local.py will also override anything specified in
the container environment through <em>PGADMIN_CONFIG_</em> prefixed variables.</p>
<p><strong>/pgadmin4/servers.json</strong></p>
<p>If this file is mapped, server definitions found in it will be loaded at launch
time. This allows connection information to be pre-loaded into the instance of
pgAdmin in the container. Note that server definitions are only loaded on first
launch, i.e. when the configuration database is created, and not on subsequent
launches using the same configuration database.</p>
<p><strong>/pgadmin4/preferences.json</strong></p>
<p>If this file is mapped, preferences defined in it will be updated at launch
time. This allows customization of preferences settings into the instance of
pgAdmin in the container. Note that preferences are only set on first
launch, i.e. when the configuration database is created, and not on subsequent
launches using the same configuration database.</p>
<p><strong>/certs/server.cert</strong></p>
<p>If TLS is enabled, this file will be used as the servers TLS certificate.</p>
<p><strong>/certs/server.key</strong></p>
<p>If TLS is enabled, this file will be used as the key file for the servers TLS
certificate.</p>
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Link to this heading"></a></h2>
<p>Run a simple container over port 80:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>pull<span class="w"> </span>dpage/pgadmin4
docker<span class="w"> </span>run<span class="w"> </span>-p<span class="w"> </span><span class="m">80</span>:80<span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_DEFAULT_EMAIL=user@domain.com&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_DEFAULT_PASSWORD=SuperSecret&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-d<span class="w"> </span>dpage/pgadmin4
</pre></div>
</div>
<p>Run a simple container over port 80, setting some configuration options:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>pull<span class="w"> </span>dpage/pgadmin4
docker<span class="w"> </span>run<span class="w"> </span>-p<span class="w"> </span><span class="m">80</span>:80<span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_DEFAULT_EMAIL=user@domain.com&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_DEFAULT_PASSWORD=SuperSecret&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION=True&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_CONFIG_LOGIN_BANNER=&quot;Authorised users only!&quot;&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_CONFIG_CONSOLE_LOG_LEVEL=10&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-d<span class="w"> </span>dpage/pgadmin4
</pre></div>
</div>
<p>Run a TLS secured container using a shared config/storage directory in
/private/var/lib/pgadmin on the host, and servers pre-loaded from
/tmp/servers.json on the host:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>pull<span class="w"> </span>dpage/pgadmin4
docker<span class="w"> </span>run<span class="w"> </span>-p<span class="w"> </span><span class="m">443</span>:443<span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-v<span class="w"> </span>/private/var/lib/pgadmin:/var/lib/pgadmin<span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-v<span class="w"> </span>/path/to/certificate.cert:/certs/server.cert<span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-v<span class="w"> </span>/path/to/certificate.key:/certs/server.key<span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-v<span class="w"> </span>/tmp/servers.json:/pgadmin4/servers.json<span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_DEFAULT_EMAIL=user@domain.com&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_DEFAULT_PASSWORD=SuperSecret&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s1">&#39;PGADMIN_ENABLE_TLS=True&#39;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-d<span class="w"> </span>dpage/pgadmin4
</pre></div>
</div>
</section>
<section id="reverse-proxying">
<h2>Reverse Proxying<a class="headerlink" href="#reverse-proxying" title="Link to this heading"></a></h2>
<p>Sometimes it’s desirable to have users connect to pgAdmin through a reverse
proxy rather than directly to the container it’s running in. The following
examples show how this can be achieved. With traditional reverse proxy servers
such as <a class="reference external" href="https://www.nginx.com/">Nginx</a>, pgAdmin is running in a container on
the same host, with port 5050 on the host mapped to port 80 on the container,
for example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>pull<span class="w"> </span>dpage/pgadmin4
docker<span class="w"> </span>run<span class="w"> </span>-p<span class="w"> </span><span class="m">5050</span>:80<span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;PGADMIN_DEFAULT_EMAIL=user@domain.com&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;PGADMIN_DEFAULT_PASSWORD=SuperSecret&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-d<span class="w"> </span>dpage/pgadmin4
</pre></div>
</div>
<section id="pgadmin-x-forwarded-configuration">
<h3>pgAdmin X-Forwarded-* Configuration<a class="headerlink" href="#pgadmin-x-forwarded-configuration" title="Link to this heading"></a></h3>
<p>pgAdmin needs to understand how many proxies set each header so it knows what
values to trust. The configuration parameters for the X-Forwarded-* options
which are used for this purpose are shown below, along with their default
values.</p>
<p>pgAdmin is configured by default to be able to run behind a reverse proxy even
on a non-standard port and these config options don’t normally need to be
changed. If you’re running an unusual configuration (such as multiple reverse
proxies) you can adjust the configuration to suit.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Number of values to trust for X-Forwarded-For</span>
<span class="n">PROXY_X_FOR_COUNT</span> <span class="o">=</span> <span class="mi">1</span>

<span class="c1"># Number of values to trust for X-Forwarded-Proto.</span>
<span class="n">PROXY_X_PROTO_COUNT</span> <span class="o">=</span> <span class="mi">0</span>

<span class="c1"># Number of values to trust for X-Forwarded-Host.</span>
<span class="n">PROXY_X_HOST_COUNT</span> <span class="o">=</span> <span class="mi">0</span>

<span class="c1"># Number of values to trust for X-Forwarded-Port.</span>
<span class="n">PROXY_X_PORT_COUNT</span> <span class="o">=</span> <span class="mi">1</span>

<span class="c1"># Number of values to trust for X-Forwarded-Prefix.</span>
<span class="n">PROXY_X_PREFIX_COUNT</span> <span class="o">=</span> <span class="mi">0</span>
</pre></div>
</div>
</section>
<section id="http-via-nginx">
<h3>HTTP via Nginx<a class="headerlink" href="#http-via-nginx" title="Link to this heading"></a></h3>
<p>A configuration similar to the following can be used to create a simple HTTP
reverse proxy listening for all hostnames with <a class="reference external" href="https://www.nginx.com/">Nginx</a>:</p>
<div class="highlight-nginx notranslate"><div class="highlight"><pre><span></span><span class="k">server</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="kn">listen</span><span class="w"> </span><span class="mi">80</span><span class="p">;</span>
<span class="w">    </span><span class="kn">server_name</span><span class="w"> </span><span class="s">_</span><span class="p">;</span>

<span class="w">    </span><span class="kn">location</span><span class="w"> </span><span class="s">/</span><span class="w"> </span><span class="p">{</span>
<span class="w">        </span><span class="kn">proxy_set_header</span><span class="w"> </span><span class="s">Host</span><span class="w"> </span><span class="nv">$host</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_pass</span><span class="w"> </span><span class="s">http://localhost:5050/</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_redirect</span><span class="w"> </span><span class="no">off</span><span class="p">;</span>
<span class="w">    </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>If you wish to host pgAdmin under a subdirectory rather than on the root of the
server, you must specify the location and set the <em>X-Script-Name</em> header which
tells the pgAdmin container how to rewrite paths:</p>
<div class="highlight-nginx notranslate"><div class="highlight"><pre><span></span><span class="k">server</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="kn">listen</span><span class="w"> </span><span class="mi">80</span><span class="p">;</span>
<span class="w">    </span><span class="kn">server_name</span><span class="w"> </span><span class="s">_</span><span class="p">;</span>

<span class="w">    </span><span class="kn">location</span><span class="w"> </span><span class="s">/pgadmin4/</span><span class="w"> </span><span class="p">{</span>
<span class="w">        </span><span class="kn">proxy_set_header</span><span class="w"> </span><span class="s">X-Script-Name</span><span class="w"> </span><span class="s">/pgadmin4</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_set_header</span><span class="w"> </span><span class="s">Host</span><span class="w"> </span><span class="nv">$host</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_pass</span><span class="w"> </span><span class="s">http://localhost:5050/</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_redirect</span><span class="w"> </span><span class="no">off</span><span class="p">;</span>
<span class="w">    </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>If Nginx is also running in a container, there is no need to map the pgAdmin
port to the host, provided the two containers are running in the same Docker
network. In such a configuration, the <em>proxy_pass</em> option would be changed to
point to the pgAdmin container within the Docker network.</p>
</section>
<section id="https-via-nginx">
<h3>HTTPS via Nginx<a class="headerlink" href="#https-via-nginx" title="Link to this heading"></a></h3>
<p>The following configuration can be used to serve pgAdmin over HTTPS to the user
whilst the backend container is serving plain HTTP to the proxy server. In this
configuration we not only set <em>X-Script-Name</em>, but also <em>X-Scheme</em> to tell the
pgAdmin server to generate any URLs using the correct scheme. A redirect from
HTTP to HTTPS is also included. The certificate and key paths may need to be
adjusted as appropriate to the specific deployment:</p>
<div class="highlight-nginx notranslate"><div class="highlight"><pre><span></span><span class="k">server</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="kn">listen</span><span class="w"> </span><span class="mi">80</span><span class="p">;</span>
<span class="w">    </span><span class="kn">return</span><span class="w"> </span><span class="mi">301</span><span class="w"> </span><span class="s">https://</span><span class="nv">$host$request_uri</span><span class="p">;</span>
<span class="p">}</span>

<span class="k">server</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="kn">listen</span><span class="w"> </span><span class="mi">443</span><span class="p">;</span>
<span class="w">    </span><span class="kn">server_name</span><span class="w"> </span><span class="s">_</span><span class="p">;</span>

<span class="w">    </span><span class="kn">ssl_certificate</span><span class="w"> </span><span class="s">/etc/nginx/server.cert</span><span class="p">;</span>
<span class="w">    </span><span class="kn">ssl_certificate_key</span><span class="w"> </span><span class="s">/etc/nginx/server.key</span><span class="p">;</span>

<span class="w">    </span><span class="kn">ssl</span><span class="w"> </span><span class="no">on</span><span class="p">;</span>
<span class="w">    </span><span class="kn">ssl_session_cache</span><span class="w"> </span><span class="n">builtin</span><span class="p">:</span><span class="mi">1000</span><span class="w"> </span><span class="s">shared:SSL:10m</span><span class="p">;</span>
<span class="w">    </span><span class="kn">ssl_protocols</span><span class="w"> </span><span class="s">TLSv1</span><span class="w"> </span><span class="s">TLSv1.1</span><span class="w"> </span><span class="s">TLSv1.2</span><span class="p">;</span>
<span class="w">    </span><span class="kn">ssl_ciphers</span><span class="w"> </span><span class="s">HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4</span><span class="p">;</span>
<span class="w">    </span><span class="kn">ssl_prefer_server_ciphers</span><span class="w"> </span><span class="no">on</span><span class="p">;</span>

<span class="w">    </span><span class="kn">location</span><span class="w"> </span><span class="s">/pgadmin4/</span><span class="w"> </span><span class="p">{</span>
<span class="w">        </span><span class="kn">proxy_set_header</span><span class="w"> </span><span class="s">X-Script-Name</span><span class="w"> </span><span class="s">/pgadmin4</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_set_header</span><span class="w"> </span><span class="s">X-Scheme</span><span class="w"> </span><span class="nv">$scheme</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_set_header</span><span class="w"> </span><span class="s">Host</span><span class="w"> </span><span class="nv">$host</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_pass</span><span class="w"> </span><span class="s">http://localhost:5050/</span><span class="p">;</span>
<span class="w">        </span><span class="kn">proxy_redirect</span><span class="w"> </span><span class="no">off</span><span class="p">;</span>
<span class="w">    </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</section>
<section id="traefik">
<h3>Traefik<a class="headerlink" href="#traefik" title="Link to this heading"></a></h3>
<p>Configuring <a class="reference external" href="https://traefik.io/">Traefik</a> is straightforward for either HTTP
or HTTPS when running pgAdmin in a container as it will automatically configure
itself to serve content from containers that are running on the local machine,
virtual hosting them at <em>&lt;container_name&gt;.&lt;domain_name&gt;</em>, where the domain
name is that specified in the Traefik configuration. The container is typically
launched per the example below:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>pull<span class="w"> </span>dpage/pgadmin4
docker<span class="w"> </span>run<span class="w"> </span>--name<span class="w"> </span><span class="s2">&quot;pgadmin4&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;PGADMIN_DEFAULT_EMAIL=user@domain.com&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;PGADMIN_DEFAULT_PASSWORD=SuperSecret&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-d<span class="w"> </span>dpage/pgadmin4
</pre></div>
</div>
<p>Note that the TCP/IP port has not been mapped to the host as it was in the
Nginx example, and the container name has been set to a known value as it will
be used as the hostname and may need to be added to the DNS zone file.</p>
<p>The following configuration will listen on ports 80 and 443, redirecting 80 to
443, using the default certificate shipped with Traefik. See the Traefik
documentation for options to use certificates from LetsEncrypt or other issuers.</p>
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="na">defaultEntryPoints</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">[&quot;http&quot;, &quot;https&quot;]</span>

<span class="k">[entryPoints]</span>
<span class="w">  </span><span class="k">[entryPoints.http]</span>
<span class="w">    </span><span class="na">address</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;:80&quot;</span>
<span class="w">      </span><span class="k">[entryPoints.http.redirect]</span>
<span class="w">        </span><span class="na">entryPoint</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;https&quot;</span>
<span class="w">  </span><span class="k">[entryPoints.https]</span>
<span class="w">    </span><span class="na">address</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;:443&quot;</span>
<span class="w">      </span><span class="k">[entryPoints.https.tls]</span>

<span class="k">[docker]</span>
<span class="na">domain</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;domain_name&quot;</span>
<span class="na">watch</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">true</span>
</pre></div>
</div>
<p>If you wish to host pgAdmin under a subdirectory using Traefik, the
configuration changes are typically made to the way the container is launched
and not to Traefik itself. For example, to host pgAdmin under <em>/pgadmin4/</em>
instead of at the root directory, the Traefik configuration above may be used if
the container is launched like this while using the version v1 of Traefik:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>pull<span class="w"> </span>dpage/pgadmin4
docker<span class="w"> </span>run<span class="w"> </span>--name<span class="w"> </span><span class="s2">&quot;pgadmin4&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;PGADMIN_DEFAULT_EMAIL=user@domain.com&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;PGADMIN_DEFAULT_PASSWORD=SuperSecret&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;SCRIPT_NAME=/pgadmin4&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-l<span class="w"> </span><span class="s2">&quot;traefik.frontend.rule=PathPrefix:/pgadmin4&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-d<span class="w"> </span>dpage/pgadmin4
</pre></div>
</div>
<p>The <em>SCRIPT_NAME</em> environment variable has been set to tell the container it is
being hosted under a subdirectory (in the same way as the <em>X-Script-Name</em> header
is used with Nginx), and a label has been added to tell Traefik to route
requests under the subdirectory to this container.</p>
<p>While using the Traefik configuration for version v2 for hosting pgAdmin under subdirectory
the container is typically launched per the example below:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>docker<span class="w"> </span>pull<span class="w"> </span>dpage/pgadmin4
docker<span class="w"> </span>run<span class="w"> </span>--name<span class="w"> </span><span class="s2">&quot;pgadmin4&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;PGADMIN_DEFAULT_EMAIL=user@domain.com&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;PGADMIN_DEFAULT_PASSWORD=SuperSecret&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-e<span class="w"> </span><span class="s2">&quot;SCRIPT_NAME=/pgadmin4&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-l<span class="w"> </span><span class="s2">&quot;traefik.frontend.pgadmin4.rule=Host(`host.example.com`) &amp;&amp; PathPrefix(`/pgadmin4`)&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span>-d<span class="w"> </span>dpage/pgadmin4
</pre></div>
</div>
</section>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3><a href="index.html">Table of Contents</a></h3>
    <ul>
<li><a class="reference internal" href="#">Container Deployment</a><ul>
<li><a class="reference internal" href="#postgresql-utilities">PostgreSQL Utilities</a></li>
<li><a class="reference internal" href="#environment-variables">Environment Variables</a></li>
<li><a class="reference internal" href="#mapped-files-and-directories">Mapped Files and Directories</a></li>
<li><a class="reference internal" href="#examples">Examples</a></li>
<li><a class="reference internal" href="#reverse-proxying">Reverse Proxying</a><ul>
<li><a class="reference internal" href="#pgadmin-x-forwarded-configuration">pgAdmin X-Forwarded-* Configuration</a></li>
<li><a class="reference internal" href="#http-via-nginx">HTTP via Nginx</a></li>
<li><a class="reference internal" href="#https-via-nginx">HTTPS via Nginx</a></li>
<li><a class="reference internal" href="#traefik">Traefik</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  </div>
<h3><a href="index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="getting_started.html">Getting Started</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="deployment.html">Deployment</a></li>
<li class="toctree-l2"><a class="reference internal" href="login.html">Login Page</a></li>
<li class="toctree-l2"><a class="reference internal" href="mfa.html">Enabling two-factor authentication (2FA)</a></li>
<li class="toctree-l2"><a class="reference internal" href="user_management.html">User Management Dialog</a></li>
<li class="toctree-l2"><a class="reference internal" href="change_ownership.html">Change Ownership Dialog</a></li>
<li class="toctree-l2"><a class="reference internal" href="change_user_password.html">Change User Password Dialog</a></li>
<li class="toctree-l2"><a class="reference internal" href="restore_locked_user.html">Lock/Restore Account</a></li>
<li class="toctree-l2"><a class="reference internal" href="ldap.html">Enabling LDAP Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="kerberos.html">Enabling Kerberos Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="oauth2.html">Enabling OAUTH2 Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="webserver.html">Enabling Webserver Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="user_interface.html">User Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="menu_bar.html">Menu Bar</a></li>
<li class="toctree-l2"><a class="reference internal" href="toolbar.html">Toolbar</a></li>
<li class="toctree-l2"><a class="reference internal" href="tabbed_browser.html">Tabbed Browser</a></li>
<li class="toctree-l2"><a class="reference internal" href="tree_control.html">Tree Control</a></li>
<li class="toctree-l2"><a class="reference internal" href="preferences.html">Preferences Dialog</a></li>
<li class="toctree-l2"><a class="reference internal" href="keyboard_shortcuts.html">Keyboard Shortcuts:</a></li>
<li class="toctree-l2"><a class="reference internal" href="search_objects.html">Search objects</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="external_database.html">External database for pgAdmin user settings</a></li>
<li class="toctree-l1"><a class="reference internal" href="connecting.html">Connecting To A Server</a></li>
<li class="toctree-l1"><a class="reference internal" href="managing_cluster_objects.html">Managing Cluster Objects</a></li>
<li class="toctree-l1"><a class="reference internal" href="managing_database_objects.html">Managing Database Objects</a></li>
<li class="toctree-l1"><a class="reference internal" href="modifying_tables.html">Creating or Modifying a Table</a></li>
<li class="toctree-l1"><a class="reference internal" href="management_basics.html">Management Basics</a></li>
<li class="toctree-l1"><a class="reference internal" href="backup_and_restore.html">Backup and Restore</a></li>
<li class="toctree-l1"><a class="reference internal" href="developer_tools.html">Developer Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="processes.html">Processes</a></li>
<li class="toctree-l1"><a class="reference internal" href="pgagent.html">pgAgent</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributions.html">pgAdmin Project Contributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="release_notes.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="licence.html">Licence</a></li>
</ul>

<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
<div id="sidebarbutton" title="Collapse sidebar">
<span>«</span>
</div>

      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"

             >index</a></li>
        <li class="right" >
          <a href="login.html" title="Login Page"

             >next</a> |</li>
        <li class="right" >
          <a href="server_deployment.html" title="Server Deployment"

             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">pgAdmin 4 8.6 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="getting_started.html" >Getting Started</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="deployment.html" >Deployment</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Container Deployment</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        <div class="related" role="navigation" aria-label="related navigation">
          <ul>
              <li class="left" style="margin-left: 10px">&#169; Copyright (C) 2013 - 2024, The pgAdmin Development Team.</li>
            <li class="right" style="margin-right: 10px"><a href="genindex.html" title="General Index" accesskey="I">index</a></li>
            <li class="right" ><a href="login.html" title="Login Page" accesskey="N">next</a> |</li>
            <li class="right" ><a href="server_deployment.html" title="Server Deployment" accesskey="P">previous</a> |</li>
          </ul>
        </div>
    </div>
  </body>
</html>