Skip to content

Instantly share code, notes, and snippets.

@fgbreel
Created June 16, 2017 12:34
Show Gist options
  • Save fgbreel/edb606ae58a526b19d94a874593d998f to your computer and use it in GitHub Desktop.
Save fgbreel/edb606ae58a526b19d94a874593d998f to your computer and use it in GitHub Desktop.
docker networking
# 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