Docker Network

04/01/2022   Docker
Docker Network
docker network --help
- docker network create test-net
=> create network test-net
- docker run -it --network=test-net ubuntu bash
=> create container with network=test-net
- docker network connect test-net containerId
=> connect network with existed container
- docker run -d \
--network todo-net --network-alias mysql \
--platform "linux/amd64" \
-v todo-vol:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=todos \
mysql:5.7
=> create container mysql
- docker run -dp 3000:3000 \
--network todo-net \
-e MYSQL_HOST=mysql \
-e MYSQL_USER=root \
-e MYSQL_PASSWORD=secret \
-e MYSQL_DB=todos \
getting-started
=> create container app
=> can connect with contaier mysql

