Skip to content
Siming Yuan edited this page Jul 31, 2020 · 3 revisions

How to Test Docker Network And Ensure Containers Can Talk To Each Other

# create a test network
docker network create test

# launch a mysql db
docker run -d --network test --name db -e MYSQL_ROOT_PASSWORD=password mysql/mysql-server:5.6

# attach to it and create user
docker exec -it db /bin/bash

# in container
mysql -p 
# password
# create user admin@localhost identified by 'cisco123';
# create user admin@'%' identified by 'cisco123';
# get out of mysql shell and container

# then create a new container on the same network
docker run -it --network test mysql/mysql-server:5.6 /bin/bash

# in shell
mysql -u admin -h db -p
# password
# you should be connected now. 

# if this step fails - your docker inter-container connectivity is having issues