I tried to upgrade my docker-compose file to V2 but links are not working.
version: '2'
services:
[...]
wordpress:
image: wordpress:4.4.2-fpm
restart: always
depends_on:
- db
links:
- db:mysql
volumes:
- ./wp:/var/www/html
environment:
- WORDPRESS_DB_NAME=....
- WORDPRESS_TABLE_PREFIX=...
db:
image: mariadb:latest
restart: always
volumes:
- ./var/mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=....
Logs :
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?
Those variables have been deprecated for many releases now, and were removed in Docker 1.10: https://docs.docker.com/compose/link-env-deprecated/
You should use the hostname provided by dns: db
The port is already hardcoded (it was in the variable name), so you can just use the port number directly.
My apologies for bumping this, but how do you suggest we provide dependent containers auth creds for a linked container? Are you suggesting we put an entry in each container's environment
?
Most helpful comment
My apologies for bumping this, but how do you suggest we provide dependent containers auth creds for a linked container? Are you suggesting we put an entry in each container's
environment
?