Yesterday, we saw how we can use the air-verse package to live reload the code. Today, let’s do the same using docker.
main.go
package main
import "fmt"
func main() {
fmt.Println("Bonjour, le monde!")
}
Create a container from the image cosmtrek/air with the working directory set to the current directory. Air will watch this directory.
docker run -it --rm \
-w "/home/me/airverse" \
-v $(pwd):/home/me/airverse \
-p 9090:9090 \
cosmtrek/air;
__ _ ___
/ /\ | | | |_)
/_/--\ |_| |_| \_ (devel), built with Go go1.23.7
watching .
building...
running...
Bonjour, le monde!
Process Exit with Code 0
Did a code change in main.go:
main.go has changed
building...
running...
Hello, world!