Skip to content

Tips and Trics

Filter out just container name

Bash
docker ps | awk '{print $NF}' | grep -w somename

How to run more complex commands | docker exec

Bash
docker exec -i container_name bash -c "cd /root/python && python myscript.py"

List containers by name

Bash
docker ps --format '{{.Names}}'

Find the log path of container

Bash
docker container inspect YOURCONTAINERNAME --format "{{ .LogPath }}

Other Stuff

  • Run OpenVPN client
Bash
docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn -v /home/$USER/temp/vpnclient-openvpn/profile-8.ovpn:/vpn/profile-8.ovpn -d dperson/openvpn-client
  • Find out "docker run command" of running container
Bash
docker inspect \
  --format "$(curl -s https://gist.githubusercontent.com/efrecon/8ce9c75d518b6eb863f667442d7bc679/raw/run.tpl)" \
  <container_name_or_ID>

Remove dangling volumes

Bash
docker volume rm $(docker volume ls -qf dangling=true)