Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose instructions don't work #2

Closed
rfdrake opened this issue Jun 7, 2016 · 1 comment
Closed

docker-compose instructions don't work #2

rfdrake opened this issue Jun 7, 2016 · 1 comment

Comments

@rfdrake
Copy link

rfdrake commented Jun 7, 2016

This:

ipam:
  image: pierrecdn/phpipam
  ports:
   - "80:80"
  links:
   - phpipam-mysql
phpipam-mysql:
  image: mysql:5.6
  environment:
   - MYSQL_ROOT_PASSWORD=my-secret-pw
  volumes:
   - /my_dir/phpipam:/var/lib/mysql

Creates an environment that looks like this:

PHPIPAM_PHPIPAM_MYSQL_1_ENV_MYSQL_MAJOR=5.6
PHPIPAM_PHPIPAM_MYSQL_1_PORT_3306_TCP=tcp://172.17.0.3:3306
PHPIPAM_MYSQL_1_ENV_MYSQL_MAJOR=5.6
PHPIPAM_MYSQL_1_PORT_3306_TCP=tcp://172.17.0.3:3306
HOSTNAME=da87c9c27341
PHPIPAM_MYSQL_ENV_MYSQL_ROOT_PASSWORD=my-secret-pw
PHPIPAM_SOURCE=https://github.com/phpipam/phpipam/archive/
PHP_INI_DIR=/usr/local/etc/php
PHPIPAM_PHPIPAM_MYSQL_1_PORT_3306_TCP_PROTO=tcp
PHPIPAM_MYSQL_1_PORT_3306_TCP_PROTO=tcp
PHPIPAM_PHPIPAM_MYSQL_1_PORT_3306_TCP_PORT=3306
PHPIPAM_MYSQL_1_PORT_3306_TCP_PORT=3306
PHPIPAM_PHPIPAM_MYSQL_1_ENV_MYSQL_VERSION=5.6.30-1debian8
PHPIPAM_MYSQL_1_ENV_MYSQL_VERSION=5.6.30-1debian8
PHPIPAM_MYSQL_PORT_3306_TCP_PORT=3306
PHPIPAM_MYSQL_PORT_3306_TCP=tcp://172.17.0.3:3306
PHPIPAM_PHPIPAM_MYSQL_1_ENV_MYSQL_ROOT_PASSWORD=my-secret-pw
PHPIPAM_MYSQL_1_ENV_MYSQL_ROOT_PASSWORD=my-secret-pw
PHPIPAM_VERSION=1.16.003
PHPIPAM_MYSQL_ENV_MYSQL_VERSION=5.6.30-1debian8
SHLVL=1
HOME=/root
PHPIPAM_MYSQL_NAME=/phpipam_ipam_1/phpipam-mysql
PHPIPAM_MYSQL_PORT_3306_TCP_PROTO=tcp
PHPIPAM_MYSQL_PORT_3306_TCP_ADDR=172.17.0.3
PHPIPAM_PHPIPAM_MYSQL_1_PORT=tcp://172.17.0.3:3306
PHPIPAM_MYSQL_1_PORT=tcp://172.17.0.3:3306
PHP_EXTRA_BUILD_DEPS=apache2-dev
PHPIPAM_PHPIPAM_MYSQL_1_NAME=/phpipam_ipam_1/phpipam_phpipam-mysql_1
PHPIPAM_MYSQL_1_NAME=/phpipam_ipam_1/phpipam-mysql_1
PHPIPAM_PHPIPAM_MYSQL_1_PORT_3306_TCP_ADDR=172.17.0.3
PHPIPAM_MYSQL_1_PORT_3306_TCP_ADDR=172.17.0.3
PHPIPAM_MYSQL_ENV_MYSQL_MAJOR=5.6
PHPIPAM_MYSQL_PORT=tcp://172.17.0.3:3306

The problem is that the HOSTNAME isn't going to be correct. It's hardcoded as "mysql" but it'll be phpipam-mysql because of the way container linking works. The MYSQL_ENV_MYSQL_ROOT_PASSWORD variable also isn't right. It seems the right way to go about it is to figure out how to derive the linked container name and never hardcode it.

If you can loop through environmental attributes you could look for

(.*)_(.*)_ENV_MYSQL_ROOT_PASSWORD 

and it should give you the name of both sides of your links. I imagine there is a more dockery way to do this, but I'm a newbie.. I was only able to identify that there was a problem, I couldn't come up with a good fix for it. :)

@pierrecdn
Copy link
Owner

Hi,
Thanks for opening an issue (and sorry to read it almost 1 year after :/ ).
You're right, the example does not work as-is, it was written and never tested :)
I updated the example with something working this time: 3738d6a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants