Created
June 16, 2017 12:34
-
-
Save fgbreel/edb606ae58a526b19d94a874593d998f to your computer and use it in GitHub Desktop.
docker networking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create network for containers | |
docker network create foobar | |
# launch mysql container within foobar network and set its name to 'database': | |
# you can also add --network-alias='mysql.foobar.local' to add a FQDN if you like. | |
docker run --detach --name=database --network=foobar --tmpfs=/var/lib/mysql/:rw,noexec,nosuid,size=7000m --env MYSQL_ALLOW_EMPTY_PASSWORD=1 --env MYSQL_DATABASE=foobar mysql:5.6 mysqld | |
# wait mysql to initialize innodb logs and become ready for connections: | |
sleep 5 | |
# launch a second container in the same network and ping or telnet 'database' host: | |
docker run -it --network=foobar debian:stretch ping database |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment