Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
MYSQL_PORT_3306_TCP_ADDR is deprecated now (use MYSQL_HOST instea…
Browse files Browse the repository at this point in the history
…d), but still supported.

Added support for more environment variables:
* MYSQL_HOST
* ALLOW_ARBITRARY
* ABSOLUTE_URI
  • Loading branch information
nazar-pc committed Dec 22, 2015
1 parent 1d029c6 commit 1e5b12a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 8 deletions.
30 changes: 26 additions & 4 deletions config.inc.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
<?php
include 'config.sample.inc.php';

// Host will default to `mysql` when using `--link db_host:mysql`, but also allows to be overridden via specifying environment variable (for Kubernetes, etc.)
$cfg['Servers'][1]['host'] = isset($_ENV['MYSQL_PORT_3306_TCP_ADDR']) ? $_ENV['MYSQL_PORT_3306_TCP_ADDR'] : 'mysql';
$cfg['Servers'][1]['AllowNoPassword'] = true;
$file_with_secret = 'config.inc.secret.php';
// TODO: MYSQL_PORT_3306_TCP_ADDR environmental variable is deprecated now and will be removed in future!
if (isset($_ENV['MYSQL_PORT_3306_TCP_ADDR'])) {
$_ENV['MYSQL_HOST'] = $_ENV['MYSQL_PORT_3306_TCP_ADDR'];
}

$hosts = isset($_ENV['MYSQL_HOST']) ? $_ENV['MYSQL_HOST'] : 'mysql';
foreach (explode(',', $hosts) as $index => $host) {
$config = &$cfg['Servers'][$index + 1];
$host = trim($host);
if (strpos($host, ':') !== false) {
list($host, $port) = explode(':', $host);
$config['port'] = $port;
}
$config['host'] = $host;
$config['AllowNoPassword'] = true;
}

if (isset($_ENV['ALLOW_ARBITRARY'])) {
$cfg['AllowArbitraryServer'] = (bool)$_ENV['ALLOW_ARBITRARY'];
}

if (isset($_ENV['ABSOLUTE_URI'])) {
$cfg['PmaAbsoluteUri'] = $_ENV['ABSOLUTE_URI'];
}

$file_with_secret = 'config.inc.secret.php';

if (!file_exists($file_with_secret)) {
$secret = hash('sha512', openssl_random_pseudo_bytes(1000));
Expand Down
33 changes: 29 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# phpMyAdmin as Docker container
This container may be used with MySQL or MariaDB linked containers.

If you like this image - you may also like set of images for [WebServer](https://github.com/nazar-pc/docker-webserver).

#How to use
With MySQL:
```bash
Expand All @@ -26,12 +28,35 @@ Sometimes it is necessary to upload big dump which doesn't fit into default limi
docker run --rm --link mysql:mysql -p 1234:80 -e UPLOAD_SIZE=1G nazarpc/phpmyadmin
```

# Difference from other similar containers with phpMyAdmin
This container is much simpler, it doesn't use any custom base, just official PHP 5.6 container with built-in Apache2 web server.
# Customize host name
By default phpMyAdmin assumes MySQL is available through `mysql` hostname. Sometimes this is not the case, so you can override this with environmental variable `MYSQL_HOST`:
```bash
docker run --rm --link mysql:mysql -p 1234:80 -e MYSQL_HOST=mariadb:9999 nazarpc/phpmyadmin
```
Examples of valid `MYSQL_HOST`:
* `mariadb` - hostname `mariadb`
* `mariadb:9999` - hostname `mariadb` with port `9999`
* `mysql, mariadb:9999` - multiple servers

# Allow connecting to arbitrary MySQL host
```bash
docker run --rm --link mysql:mysql -p 1234:80 -e ALLOW_ARBITRARY=1 nazarpc/phpmyadmin
```

# Custom URI of phpMyAdmin instance
Sometimes phpMyAdmin may determine its own URI incorrectly. Usually you can fix it by correcting virtual host of revers proxy, but sometimes it might be useful to specify URI explicitly:
```bash
docker run --rm --link mysql:mysql -p 1234:80 -e ABSOLUTE_URI=https://domain.tld/phpmyadmin nazarpc/phpmyadmin
```

# Difference from other similar images with phpMyAdmin
This image doesn't use any custom base, just official PHP 5.6 container with built-in Apache2 web server.
There is support for importing SQL dumps in all compression formats supported by phpMyAdmin.
There is possibility to connect to multiple servers of your choice or even to arbitrary servers if necessary.

Also this container generates `blowfish_secret` configuration option (unique for each container instance, you don't have to rebuild it yourself), so that you will automatically use cookie sessions (for your convenience).
Also this image generates `blowfish_secret` configuration option (unique for each container instance, you don't have to rebuild it yourself) on each container start, so that you will automatically use cookie sessions (for your convenience).

Plus, I'll try to keep it up to date with new releases of phpMyAdmin and PHP (feel free to ping me if I miss some release), so, by using `nazarpc/phpmyadmin` image you'll always have latest versions of both of them.
Plus, I'll try to keep it up to date with new releases of phpMyAdmin (as well as PHP itself and other software inside image), so, by using `nazarpc/phpmyadmin` image you'll always have latest versions.

#Questions?
Open an issue and ask your question there:)
Expand Down

0 comments on commit 1e5b12a

Please sign in to comment.