I have created successfully(all is working) docker-compose file in my linux virtualbox machine. Then I took it to my mac. After creating the containers I tried to access the webpage, but browser refused to access it. I then took official php container and tried that with this compose file, it is also not working in mac. I think the problem is the creation of a static ip, but can not figure out what I am doing wrong?
What am i doing wrong in this compose file(how can i create the static ip that works in mac)?
Why static ip works in linux, but not in mac?
For the future where can I find information about the differences of network creation to linux and mac host(how they different and why)?
My docker-compose file:
version: '2'
services:
web:
container_name: app1
restart: always
build:
context: /home/docker/Documents/app1
dockerfile: Dockerfile
ports:
- "80"
depends_on:
- db
networks:
vpcbr:
ipv4_address: 10.5.0.5
tty: true
db:
container_name: app1_db
restart: always
image: mysql:5.6
ports:
- "3306"
networks:
vpcbr:
ipv4_address: 10.5.0.6
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=magento2
networks:
vpcbr:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1
I have found this post from stackoverflow.com/. In it user @zainengineer writes that “Modern docker-compose will automatically create containers with static ip for you”. I can not understand, does that mean, when I create container using docker-compose v3 that the container ip is stored somewhere and because of that static ip is only in v2? I have not found any additional information about that in docker documentation.