Linux & Docker Commands Reference & Troubleshooting

We’ve published these commands for our developers for reference purposes. They are publicly visible as it might be helpful for other developers as well:


#stop all containers:
docker stop $(docker ps -a -q)

# Restart docker service
sudo systemctl restart docker.service

Recreate all container
docker-compose up --build --force-recreate --no-deps

#stop all containers by force
docker kill $(docker ps -q)

#remove all containers
docker rm $(docker ps -a -q)

#remove all docker images
docker rmi $(docker images -q)

#purge the rest
docker system prune --all --force --volumes

#Find IP of a container
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' [container_name]

#Show docker logs
docker-compose logs

#Show docker process
docker-compose ps

Execute mysqldump in container

docker exec [container_name] sh -c 'exec mysqldump --all-databases -uroot -p[password]' > /home/user/all-databases.sql

Error response: Could not kill running container runc did not terminate successfully: container_linux.go:392: init process caused “permission denied”

This can happen if apparmor prevents stopping the docker container.
One solution is to uninstall apparmor and restarting the docker service:

sudo apt-get purge --auto-remove apparmor
sudo service docker restart
docker system prune --all --volumes

sudo systemctl restart docker
sudo systemctl daemon-reload

Error starting userland proxy: listen tcp bind: address already in use

Find PID and kill it:

sudo netstat -nlpt |grep 3306

sudo kill [pid]



Number of open connections per ip
netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n

Show all connected ip addresses to a certain port
netstat -an |grep 443
netstat -an |grep 80

Count connections per IP
netstat -an | grep 80 | wc -l
netstat -an | grep 443 | wc -l

Firewall iptables

Firewall Block IP Adress
sudo iptables -A INPUT -s [IP ADDRESS] -j DROP

Allow access from a specific IP address
sudo iptables -A INPUT -s -p tcp –destination-port 3306 -j ACCEPT

Unban IP addresses blocked by fail2ban

iptables -D [chain] [line] z.B.
iptables -D f2b-wordpress-hard 1

Firewall Rules

  • sudo ufw default deny incoming
  • sudo ufw default allow outgoing
  • sudo ufw allow ssh
  • sudo ufw allow 1000
  • sudo ufw allow http
  • sudo ufw allow 443
  • sudo ufw allow from to any port 3306 (Local IP address)
  • sudo ufw allow from to any port 3306 (Amazon DBS)
  • sudo ufw deny from


Change MySQL password authentication module tomysql_native_password.

Needed for upgrading from 7.X to mysql 8.x

ALTER USER ‘user’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password1’;

Debug xDebug:-)

If your code editor does not connect to xDebug create a file `test.php` in your app folder with some code and add a breakpoint to it. Then run the command below to test it:

PHP_IDE_CONFIG="serverName=tests" php -dxdebug.remote_autostart=1 -dxdebug.remote_enable=1 -dxdebug.default_enable=1 -dxdebug.remote_connect_back=1 -dxdebug.remote_port=9001 -dxdebug.idekey=PHPSTORM -dxdebug.remote_host= test.php

Login reloads the login prompt

If you try to login to KDE and the login form reloads after entering correct credentials try the commands below:

systemctl stop gdm.service
systemctl restart gdm.service
sudo dpkg-reconfigure gdm3