README.md 5.16 KB
Newer Older
pierrecdn's avatar
pierrecdn committed
1 2 3 4
# docker-phpipam

phpIPAM is an open-source web IP address management application. Its goal is to provide light and simple IP address management application.

5
phpIPAM is developed and maintained by Miha Petkovsek, released under the GPL v3 license, project source is [here](https://github.com/phpipam/phpipam).
pierrecdn's avatar
pierrecdn committed
6

7
Learn more on [phpIPAM homepage](http://phpipam.net).
pierrecdn's avatar
pierrecdn committed
8

pierrecdn's avatar
pierrecdn committed
9
![phpIPAM logo](http://phpipam.net/wp-content/uploads/2014/12/phpipam_logo_small.png)
pierrecdn's avatar
pierrecdn committed
10 11 12 13 14

## How to use this Docker image

### Mysql

15
Run a MySQL database, dedicated to phpipam.
pierrecdn's avatar
pierrecdn committed
16 17 18 19 20

```bash
$ docker run --name phpipam-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -v /my_dir/phpipam:/var/lib/mysql -d mysql:5.6
```

21
Here, we store data on the host system under `/my_dir/phpipam` and use a specific root password.
pierrecdn's avatar
pierrecdn committed
22

23
### Phpipam
pierrecdn's avatar
pierrecdn committed
24 25

```bash
pierrecdn's avatar
pierrecdn committed
26
$ docker run -ti -d -p 80:80 -e MYSQL_ENV_MYSQL_ROOT_PASSWORD=my-secret-pw --name ipam --link phpipam-mysql:mysql pierrecdn/phpipam
pierrecdn's avatar
pierrecdn committed
27 28
```

29
We are linking the two containers and exposing the HTTP port.
pierrecdn's avatar
pierrecdn committed
30

31
### First install scenario
pierrecdn's avatar
pierrecdn committed
32

pierrecdn's avatar
pierrecdn committed
33
* Browse to `http://<ip>[:<specific_port>]/install/`
pierrecdn's avatar
pierrecdn committed
34 35 36 37 38 39 40 41 42 43 44 45 46
* Step 1 : Choose 'Automatic database installation'

![step1](https://cloud.githubusercontent.com/assets/4225738/8746785/01758b9e-2c8d-11e5-8643-7f5862c75efe.png)

* Step 2 : Re-Enter connection information

![step2](https://cloud.githubusercontent.com/assets/4225738/8746789/0ad367e2-2c8d-11e5-80bb-f5093801e139.png)

* Note that these two first steps could be swapped by patching phpipam (see https://github.com/phpipam/phpipam/issues/25)
* Step 3 : Configure the admin user password

![step3](https://cloud.githubusercontent.com/assets/4225738/8746790/0c434bf6-2c8d-11e5-9ae7-b7d1021b7aa0.png)

47
* You're done !
pierrecdn's avatar
pierrecdn committed
48 49 50

![done](https://cloud.githubusercontent.com/assets/4225738/8746792/0d6fa34e-2c8d-11e5-8002-3793361ae34d.png)

51
### Docker compose
pierrecdn's avatar
pierrecdn committed
52

53
You can also create an all-in-one YAML deployment descriptor with Docker compose, like this:
pierrecdn's avatar
pierrecdn committed
54 55

```yaml
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
version: '2'

services:
  mysql:
    image: mysql:5.6
    environment:
      - MYSQL_ROOT_PASSWORD=my-secret-pw
    restart: always
    volumes:
      - db_data:/var/lib/mysql
  ipam:
    depends_on:
      - mysql
    image: pierrecdn/phpipam
    environment:
71
      - MYSQL_ENV_MYSQL_USER=root
pierrecdn's avatar
pierrecdn committed
72
      - MYSQL_ENV_MYSQL_ROOT_PASSWORD=my-secret-pw
73
      - MYSQL_ENV_MYSQL_HOST=mysql
74 75 76 77
    ports:
      - "80:80"
volumes:
  db_data:
pierrecdn's avatar
pierrecdn committed
78 79 80 81
```

And next :

82
```bash
pierrecdn's avatar
pierrecdn committed
83 84 85
$ docker-compose up -d
```

86
You can also point the `MYSQL_ENV_PASSWORD_FILE` environment variable to a file,
Stijn Vermeiren's avatar
Stijn Vermeiren committed
87 88 89 90 91 92 93 94 95
in which case the contents of this file will be used as the password.
This makes it possible to use docker secrets for instance:

```yaml
version: '3'

services:
  ipam:
    environment:
96
      - MYSQL_ENV_MYSQL_PASSWORD_FILE=/run/secrets/phpipam_mysql_root_password
Stijn Vermeiren's avatar
Stijn Vermeiren committed
97 98 99 100 101 102
    secrets:
      - phpipam_mysql_root_password
```

The secret can be created by running `echo my-secret-pw | docker secret create phpipam_mysql_root_password -`

103 104 105 106 107 108 109 110 111 112 113 114 115
### Advanced Configuration

Here is the list of the available environment variables in the phpipam container, pass them to docker using `-e`.
None of them are actually needed to run the container, this is only to tweak the behavior.

| Environment variable           | Default value | Description                                                                                              |
| ------------------------------ |:-------------:| --------------------------------------------------------------------------------------------------------:|
| MYSQL_ENV_MYSQL_HOST           | mysql         | The host used to reach the MySQL instance                                                                |
| MYSQL_ENV_MYSQL_USER           | root          | The user to connect the MySQL instance                                                                   |
| MYSQL_ENV_MYSQL_ROOT_PASSWORD  | (empty)       | The MySQL password. Can be set using the Web UI during the first install                                 |
| MYSQL_ENV_MYSQL_DB             | phpipam       | The name of the MySQL DB to connect to                                                                   |
| MYSQL_ENV_MYSQL_PASSWORD_FILE  | (empty)       | A file containing the password (if not using MYSQL_ROOT_PASSWORD) this allows to leverage docker secrets |
| PHPIPAM_BASE                   | /             | The base URI under which phpipam runs. Useful when performing rewrites with a reverse-proxy              |
116 117
| GMAPS_API KEY                  | (empty)       | Google Maps API Key, used to display maps of your devices                                                |
| GMAPS_API_GEOCODE_KEY          | (empty)       | Google Maps Geocode API Key, used to find coordinates from an address/ a location of your device         |
118 119 120 121 122 123 124 125 126

### Specific integration (HTTPS, multi-host containers, etc.)

Regarding your requirements and docker setup, you've to expose resources.

For HTTPS, run a reverse-proxy in front of your phpipam container and link it to.

For multi-host containers, expose ports, run etcd or consul to make service discovery works etc.

pierrecdn's avatar
pierrecdn committed
127 128
### Notes

129 130
phpIPAM is under heavy development by the amazing Miha.
To upgrade the release version, just change the `PHPIPAM_VERSION` environment variable to the target release (see [here](https://github.com/phpipam/phpipam/releases)).