Last active
December 2, 2017 03:17
-
-
Save joselo/18ee97a03bc6f0ce533a80c7fbaf9122 to your computer and use it in GitHub Desktop.
Docker Useful Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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