Skip to content

Docker General🔗

SSH to a Container🔗

docker exec -it mysqldb "bash"

Update All Downloaded Images🔗

docker images |grep -v REPOSITORY|awk '{print $1}'|xargs -L1 docker pull

Purging All Unused or Dangling Images🔗

Purging All Unused or Dangling Images, Containers, Volumes, and Networks Docker provides a single command that will clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container):

docker system prune

To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command:

docker system prune -a

Portainer.io Docker UI management🔗

Portainer.io

Find Container IP🔗

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

Show all Containers🔗

docker ps -a

Create mysql Docker with Mapping to Host🔗

docker run --name mysqldb -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="qweQWE123" -p 3306:3306 -it mysql/mysql-server:5.7

Exit Container Without Closing It🔗

crtl+shift+D

Container Specific Logs (to view the output of commands running in container)🔗

docker logs mysqldb

Create Volume and Map Container to it🔗

docker volume create vol1
docker run --name mysqldb_map -v vol1:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="qweQWE123" -p 3306:3306 -it mysql/mysql-server:5.7

View Details for Specific Docker🔗

docker inspect mysqldb_map

Rename a Container🔗

docker rename CONTAINER NEW_NAME

Copy Files Into Docker Container🔗

docker cp 1.txt mycontainer:/1.txt

Run Docker to Map Port 9000 to Forward 3306🔗

docker run -d -p 3306:9000 dockercloud/mysql

Allow Outbound Forwarding for the Container to the World🔗

on the host server run the following command:

sysctl net.ipv4.conf.all.forwarding=1
iptables -P FORWARD ACCEPT

Comments