Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trungquy/05828875b1439e48d7f97ba43a457579 to your computer and use it in GitHub Desktop.
Save trungquy/05828875b1439e48d7f97ba43a457579 to your computer and use it in GitHub Desktop.
Assign fixed IP for docker container
# 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