Skip to content

Instantly share code, notes, and snippets.

@lucaspar
Created June 24, 2023 21:39
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 lucaspar/64ae5dc444302480e71eb08b9a111f54 to your computer and use it in GitHub Desktop.
Save lucaspar/64ae5dc444302480e71eb08b9a111f54 to your computer and use it in GitHub Desktop.
Debugging in containers

Debugging in containers

Tired of "command not found" - these lines will install commonly used tools to debug networking, read logs, and other things.

Start a shell as root inside the container

CONTAINER_KEYWORD="spark"
CONTAINER_NAME=$(docker ps | grep -i "${CONTAINER_KEYWORD}" | head -n 1 | awk '{print $NF}')
echo "CONTAINER_NAME: ${CONTAINER_NAME}"
docker exec -u 0 -it "${CONTAINER_NAME}" bash

Debian-based

Install some utilities

apt update
apt install dnsutils sudo curl wget less vim git net-tools iproute2 iputils-ping exa
alias ls='exa'
alias la='ls -alh'

More utilities:

apt install telnet netcat-openbsd tcpdump nmap socat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment