One of the issues that beginners will encounter is IP assignment to docker containers. By default, IP address are assigned as "first come, first serve". Meaning that depending on the order you start your containers, they can have different IP address.
If you are anything like me, I tend to use multiple environments. While QA would be testing on environment A, I would be developing on environment B. Since I tend not to start up my containers in a specific order, having different IP Address would cause some hiccups because I would need to reconfigure MySQL Workbench to reflect the new IP Address.
So to fix this minor inconvience, I was able to fix this issue by:
doing the following steps:
1) Create a docker network
2) Assign an IP address to the container
3) Enjoy the fruits of my labor
*Command Sample*
docker network create --driver bridge --subnet 172.18.0.0/16 --gateway 172.18.0.1 docker-network
docker network connect --ip 172.18.0.2 docker-network mysql-5.6
docker network connect --ip 172.18.0.3 docker-network mysql-5.7
docker network disconnect docker-network mysql-5.6
docker network disconnect docker-network mysql-5.7
Watch video Docker 101: How To Assign Static IP to Docker Containers online without registration, duration hours minute second in high quality. This video was added by user WebDev Dave 26 July 2018, don't forget to share it with your friends and acquaintances, it has been viewed on our site 39,785 once and liked it 488 people.