When you create a container and pass in
/bin/bash as the command, that's as far as Docker cares. When the container restarts, it will start up another instance of
Docker doesn't watch your shell session and see what things you do after it starts the command. If you want to actually run
./main as the command of the container, then you'll need to pass in
/go/src/app/main as the command instead of
Additionally, compiling code is something better done during the image build phase instead of at container runtime.