Git • Docker • Docker Compose • Useful Commands
git init
Create a new local repository
git clone https://github.com/user/repo.git
Download a remote repository
git status
Show changed/staged files
git add .
Stage all changes for commit
git commit -m "feat: add login"
Save staged changes with a message
git push origin main
Upload commits to remote
git pull origin main
Fetch + merge remote changes
git checkout -b feature/login
Create and switch to new branch
git checkout main
Switch to an existing branch
git merge feature/login
Merge a branch into current one
git log --oneline --graph
Show compact commit history
git stash
Temporarily save uncommitted work
git stash pop
Restore last stashed changes
git reset --soft HEAD~1
Undo commit but keep changes staged
git checkout -- file.txt
Restore file to last commit state
git branch -d feature/login
Remove a local branch
git remote -v
List remote URLs
git diff
Show unstaged file differences
docker build -t myapp:latest .
Build image from Dockerfile in current dir
docker run -d -p 8080:80 --name web myapp
Run detached, map port 8080 to 80
docker ps
Show active containers
docker ps -a
Include stopped containers
docker stop web
Gracefully stop a running container
docker rm web
Delete a stopped container
docker images
Show all local images
docker rmi myapp:latest
Delete a local image
docker logs -f web
Follow container logs in real-time
docker exec -it web /bin/sh
Open shell inside running container
docker pull nginx:alpine
Download image from Docker Hub
docker inspect web
Show detailed container info (IP, mounts…)
docker system prune -a
Remove all unused images, containers, networks
docker cp file.txt web:/app/
Copy local file into container
docker volume ls
Show all Docker volumes
docker network ls
Show all Docker networks
docker compose up -d
Start all services in background
docker compose down
Stop and remove containers + networks
docker compose down -v
Also remove named volumes
docker compose up -d --build
Force rebuild images before starting
docker compose logs -f api
Follow logs for a specific service
docker compose ps
Show running compose services
docker compose exec api sh
Open shell in a running service
docker compose restart api
Restart one specific service
docker compose up -d --scale api=3
Run 3 instances of the api service
docker compose pull
Download latest images for all services
find . -name "*.log"
Search for files matching a pattern
grep -r "TODO" ./src
Recursively search for text in folder
du -sh *
Show size of each item in current dir
df -h
Show available disk space
watch -n 2 ls -la
Re-run command every 2 seconds
lsof -i :3000
Show which process uses port 3000
kill -9 $(lsof -t -i :3000)
Force kill process using port 3000
tar -czf archive.tar.gz ./folder
Compress folder to .tar.gz
tar -xzf archive.tar.gz
Extract .tar.gz archive
ssh user@192.168.1.10
Connect to remote server via SSH
scp file.txt user@server:/path/
Copy file to remote server
curl -s https://api.example.com/data | jq
Fetch URL and pretty-print JSON
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' https://api.example.com
Send JSON POST request
chmod +x script.sh
Add execute permission to file
echo $PATH
Print the value of a variable
wc -l file.txt
Count number of lines
tail -f /var/log/app.log
Follow new lines in a log file
ps aux | grep node
Find running processes by name