Skip to content

Instantly share code, notes, and snippets.

@joselo
Last active December 2, 2017 03:17
Show Gist options
  • Save joselo/18ee97a03bc6f0ce533a80c7fbaf9122 to your computer and use it in GitHub Desktop.
Save joselo/18ee97a03bc6f0ce533a80c7fbaf9122 to your computer and use it in GitHub Desktop.
Docker Useful Commands
# Remove unused images
docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")
# Remove dangling images
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
# Ejecutar bash dentro de un servicio docker
$ docker-compose exec <service id> bash
# List containers
docker ps -a
# Kill container
docker rm -fv CONTAINER_ID
# List Images
docker images
# Containers
- stop all containers: docker kill $(docker ps -q)
- remove all containers CUIDADO SI SE ELIMINA, SE VOLVERA A CREAR CON UN HASH DISTINTO PARA EL VOLUMEN.
docker rm $(docker ps -a -q)
- remove all docker images. docker rmi $(docker images -q)
# Remover todos los volumens colgados
$ docker volume rm `docker volume ls -q -f dangling=true`
# Restore database
docker exec -i qms_db_1 psql -U postgres < qms_production.back
# LINUX RUN WITHOUT SUDO (After this restart the machine or logout and login again)
sudo gpasswd -a USERNAME docker
sudo systemctl restart docker
# Interctive with database to backup or restore
# Postgres
$ docker exec -i yourdb_db_1 psql -U postgres < yourdb_development.back
# Mysql
$ docker exec -i wordpress_db_1 mysql -uroot -p -v -e "create database DATABASE_NAME"
$ docker exec -i wordpress_db_1 mysql -uroot -pMYSQL_PASSWORD -v DATABASE_NAME < database_name.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment