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
package main | |
import ( | |
"net" | |
"os/exec" | |
"github.com/k0kubun/pp" | |
) | |
func Hosts(cidr string) ([]string, error) { |
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
# So you want to pipe shell scripts to docker. But docker runs the container's command as PID 1. | |
# Linux doesn't set up signal handlers for PID 1. | |
# This gives you the following problems: | |
# 1. The script can't kill itself: | |
echo 'kill $$; echo "Still alive"' | docker run -i --rm alpine sh | |
# 2. You can't kill the script from outside with a normal kill: | |
echo "sleep 1000" | docker run -i --rm alpine sh & sleep 1 && kill $! | |
docker ps # it didn't die | |
#==== Solving problem 1 ==== |