Twitter (not set)
Blog http://daniel-ortega.mx/posts/
Website https://www.linkedin.com/in/gatero/

0

Remove all container from an specific network (docker)

 $ docker ps -a -f network=$NETWORK --format='{{.ID}}' | xargs docker rm -f

— by gatero on Aug. 17, 2018, 4:38 p.m.

Explanation

docker ps -a -f network=$NETWORK --format='{{.ID}}' returns the id's of all container that are subscribed to the network and pass the output to xargs docker rm -f that stop and deletes each container

0

Up all docker services as detached mode over all immediate subdirectories

 $ for dir in $(ls -d */); do eval $(cd $PWD/$dir && docker-compose up -d && cd ..); done;

— by gatero on Aug. 17, 2018, 4:31 p.m.

Explanation

Supposing that you are in a directory that contains many subdirectories with a docker-compose file each one and instead of up one by one manually you want run all at time, well this is a helpful command for this purpose

0

Find and replace string inside specific files

 $ grep -ril '$SEARCH_PATTERN' src | sed -i 's/$FIND_PATTERN/$REPLACE_PATTERN/g'

— by gatero on Aug. 17, 2018, 4:18 p.m.

Explanation

This command search for files that contain and an specific string and then find a pattern on those files and replace it