Docker cheat sheet

TaskCommand
Get Bash shell in a container docker exec -it <container name> /bin/bash 
Clear no-tags images
(or dangling images)
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
Get docker instance’s IPdocker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
Dump Postgres database to .sql filedocker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql

-U postgres : database username
Import .sql files to Postgres dbcat your_dump.sql | docker exec -i your-db-container psql -U postgres
Copy file/folder from local to dockerdocker cp foo.txt container_id:/foo.txt
docker cp src/. container_id:/target
Copy file/folder from docker to localdocker cp container_id:/foo.txt foo.txt
docker cp container_id:/src/. target
Somehow Docker lost access to Internetsudo service docker restart
systemctl restart docker
Docker cheat sheet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s