Last active
June 21, 2022 14:07
-
-
Save achraf-jeday/bd3fa54bef97967cfc290d185b887936 to your computer and use it in GitHub Desktop.
Docker and drush most used commands (drupal 8)
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
List all containers (only IDs): | |
docker ps -aq | |
Stop all running containers: | |
docker stop $(docker ps -aq) | |
Or this one: | |
docker-compose down --remove-orphans | |
Or this one: | |
docker rm -f $(docker ps -aq) | |
Stop a specific container by image name: | |
docker ps -a -q --filter ancestor=<image-name> | |
Or this one: | |
docker stop <CONTAINER-ID> | |
Delete just one container and its volume using service name: | |
docker-compose rm -s -v yourService | |
Delete all containers: | |
docker rm -f $(docker ps -a -q) | |
Remove all images: | |
docker rmi -f $(docker images -qa) | |
Run containers: | |
docker-compose up -d | |
Composer install: | |
composer install -nv --prefer-dist --optimize-autoloader | |
Drush commands: | |
cd web/ | |
alias drush="../vendor/bin/drush" | |
drush cim -y && drush updb -y && drush uli && drush cr | |
List images: | |
docker images | |
list volumes: | |
docker volume ls | |
list networks: | |
docker network ls | |
Cleanup volumes: | |
docker volume prune -f | |
Or this one: | |
docker volume rm $(docker volume ls -q) | |
Cleanup networks: | |
docker network prune -f | |
Remove all containers that aren't running. | |
docker rm -vf $(docker ps -a -q --filter "status=exited") | |
Remove untagged images. | |
docker rmi -f $(docker images -q -f "dangling=true") | |
Remove unused volumes using "rm" or "prune". | |
docker volume rm -f $(docker volume ls -f "dangling=true") | |
docker volume prune -f | |
Remove unused networks. | |
docker network prune -f | |
Get a Docker container's IP address from the host (to access a url from inside another container): | |
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id | |
Print container logs: | |
docker-compose logs <CONTAINER-ID> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment