Docker networking #notetoself

Networking

  • List network setup: docker network ls
  • List: docker network inspect -f '{{range .IPAM.Config}}{{.Subnet}}{{end}}' [networkid]
  • List IPs of all containers.  docker network inspect -f '{{json .Containers}}' [networkid] | jq '.[] | .Name + ":" + .IPv4Address'
  • View host setup: docker exec [nameofnode] cat /etc/hosts
  • Running a named container: docker run -name api1 -p 8080:80 gcp-api

Installing ping in the container: https://stackoverflow.com/questions/39901311/docker-ubuntu-bash-ping-command-not-found
Setting up a network:
https://www.digitalocean.com/community/questions/how-to-ping-docker-container-from-another-container-by-name

Docker networking for Dummies (like me) https://www.freecodecamp.org/news/how-to-get-a-docker-container-ip-address-explained-with-examples/

Classic Setup (web, api, sql)

Setting up the classical environment of having the following 3 components, Web, API, SQL

A few extra notes

A note to self. Use remote command bash when the docker attach command hangs: docker exec -it [container-id] bash

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s