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

Using version 2 of docker-compose file descriptor, the database links is not found by the wordpress container #134

Closed
angelcervera opened this issue Mar 25, 2016 · 2 comments

Comments

@angelcervera
Copy link

Error in the wordpress container:

wordpress_1 | error: missing WORDPRESS_DB_HOST and MYSQL_PORT_3306_TCP environment variables
wordpress_1 |   Did you forget to --link some_mysql_container:mysql or set an external db
wordpress_1 |   with -e WORDPRESS_DB_HOST=hostname:port?

Compose file:

version: '2'
services:
  wordpress:
    image: wordpress
    links:
      - db:mysql
    ports:
      - 8080:80
  db:
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: temporalpass

Environment:

~$ lsb_release -a; docker --version; docker-compose --version
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.10
Release:    15.10
Codename:   wily
Docker version 1.10.3, build 20f81dd
docker-compose version 1.6.2, build 4d72027
@ailic
Copy link

ailic commented Mar 26, 2016

This comes with composer file, version 2. It's stated in Docker documentation.

Note: Environment variables are no longer the recommended method for connecting to linked services. Instead, you should use the link name (by default, the name of the linked service) as the hostname to connect to. See the docker-compose.yml documentation for details.

What you have to do is to set the link name as the host name on which you wish to connect.

Your wordpress section should look like this now:

wordpress:
  image: wordpress
  environment:
    WORDPRESS_DB_HOST: db
    WORDPRESS_DB_NAME: <db name>
    WORDPRESS_DB_PASSWORD: <db pass>
  ports:
    - 8080:80

@angelcervera
Copy link
Author

F*ck! It is in the first note of the documentation! More big and clear impossible. I need other glasses.

Tested and working.

Thx.

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