Skip to content

Instantly share code, notes, and snippets.

@mildsunrise
Created February 22, 2019 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mildsunrise/9051867122fa08b09fb8e4cc58de41bb to your computer and use it in GitHub Desktop.
Save mildsunrise/9051867122fa08b09fb8e4cc58de41bb to your computer and use it in GitHub Desktop.
Useful Docker commands

Useful Docker commands

Search for Drupal or Drupal-like installs in all started containers (assumes overlay2 storage used):

sudo docker inspect $(docker ps --format '{{.ID}}') --format '{{.GraphDriver.Data.MergedDir}} {{.Name}}' | xargs -L1 bash -c 'echo Scanning container "$1"; sudo find $0 -name authorize.php'

docker-ps Like docker ps -a but with less info:

sudo docker ps -a --format "table {{.ID}}\t{{.Status}}\t{{.Names}}\t{{.Image}}"

docker-ips Command to get a nice list of containers and their IPs (add | cowthink -ny | lolcat for extra points):

docker network inspect cts | python3 -c 'import json, sys; cts = sorted(json.loads(sys.stdin.read())[0]["Containers"].items(), key=lambda c: int(c[1]["IPv4Address"].split("/")[0].split(".")[-1])); print("\n".join(n[:6]+" "+c["IPv4Address"]+" "+c["Name"] for n, c in cts))'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment