# Created on savesnippets.com ยท https://savesnippets.com/QP6lJcSh6U9u2Q # Interactive shell in a running container docker exec -it myapp_web_1 sh docker exec -it myapp_web_1 bash # if bash is installed # Run a one-off command (no TTY needed) docker exec myapp_db_1 mysqldump -u root -p"$PW" app > backup.sql # Run as a different user docker exec -u root -it myapp_web_1 apt-get update # Get env vars from inside docker exec myapp_web_1 env | sort # Find which compose service is which container docker compose ps # human-readable table docker compose ps -q web # just the container ID for the 'web' service