unbreakdocker.go 727 B

12345678910111213141516171819202122
  1. package internal
  2. import (
  3. "os"
  4. "os/exec"
  5. )
  6. func UnbreakDocker() {
  7. // XXX(Xe): This is bad code. Do not do this.
  8. //
  9. // I have to do this because I'm running from inside the context of a dev
  10. // container. This dev container runs in a different docker network than
  11. // the valkey test container runs in. In order to let my dev container
  12. // connect to the test container, they need to share a network in common.
  13. // The easiest network to use for this is the default "bridge" network.
  14. //
  15. // This is a horrifying monstrosity, but the part that scares me the most
  16. // is the fact that it works.
  17. if hostname, err := os.Hostname(); err == nil {
  18. exec.Command("docker", "network", "connect", "bridge", hostname).Run()
  19. }
  20. }