Created
May 24, 2016 23:41
-
-
Save trungquy/05828875b1439e48d7f97ba43a457579 to your computer and use it in GitHub Desktop.
Assign fixed IP for docker container
This file contains 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 a new bridge network with your subnet and gateway for your ip block | |
$ docker network create --subnet 203.0.113.0/24 --gateway 203.0.113.254 iptastic | |
# run a nginx container with a specific ip in that block | |
$ docker run --rm -it --net iptastic --ip 203.0.113.2 nginx | |
# curl the ip from any other place (assuming this is a public ip block duh) | |
$ curl 203.0.113.2 | |
# BOOM golden | |
Source: https://blog.jessfraz.com/post/ips-for-all-the-things/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment