I have a docker-compose as follow:
version: '3.2'
services:
web:
build: .
image: lap
volumes:
- ./webroot:/var/www/app
- ./configs/php.ini:/usr/local/etc/php/php.ini
- ./configs/vhost.conf:/etc/apache2/sites-available/000-default.conf
links:
- dbs:mysql
dbs:
image: mysql
ports:
- "3307:3306"
environment:
- MYSQL_ROOT_PASSWORD=root
volumes:
- ./configs/conf.d:/etc/mysql/conf.d
- /var/mysql:/var/lib/mysql
docker --version
Docker version 17.05.0-ce, build 89658be
docker-compose --version
docker-compose version 1.13.0, build 1719ceb
lsb_release -a
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 8.10 (jessie) Release: 8.10 Codename: jessie
If I run following commands and check /etc/host on php container I see no linking ( which I see when I do docker container --link )
docker-compose up -d
docker exec -it web_1 bash
root@web_1> cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.3 9c401ea7d031
The dbs
container is assigned 127.18.0.2
ip address, what I was expecting was something like this in above /etc/hosts
127.18.0.2 dbs mysql
I see the same behavior in one of my Mac OSX system , probably I am doing something wrong or missing anything ?
/etc/hosts
– Nikson Kanti Paul