Skip to content

Instantly share code, notes, and snippets.

@wooyey
Last active March 2, 2023 08:45
Show Gist options
  • Save wooyey/006596c3cfa9e324780d6d56eb734fdb to your computer and use it in GitHub Desktop.
Save wooyey/006596c3cfa9e324780d6d56eb734fdb to your computer and use it in GitHub Desktop.
Remove dangling docker images

Docker cheat-sheet

Cleanup

Remove dangling images:

docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

Remove all stopped docker containers:

docker rm $(docker ps -a -q)

Publish port already running docker

iptables -t nat -A DOCKER -p tcp --dport <port_out> -j DNAT --to-destination <container_ip>:<port_in>
iptables -t nat -A POSTROUTING -j MASQUERADE -p tcp --source <container_ip> --destination <container_ip> --dport <port_out>
iptables -A DOCKER -j ACCEPT -p tcp --destination <container_ip> --dport <port_out>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment