Build it:
$ docker build -t greeter .
Run it:
$ docker run -it greeter
Enter your name: Nick
Hello Nick!
FROM golang | |
ADD main.go ./ | |
RUN go build -o greeter main.go | |
CMD ["./greeter"] |
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func main() { | |
var name string | |
fmt.Printf("Enter your name: ") | |
fmt.Fscanln(os.Stdin, &name) | |
fmt.Printf("Hello %s!\n", name) | |
} |