Run Go application in Docker Container
Generate a Go Application
Create Project folder HelloWorld. Open VS Code and type in Terminal :
|
|
Create a file hello.go with the following content :
|
|
Run the application :
|
|
Create Docker Image
Create a docker file named ‘Dockerfile’ and add the following content :
|
|
alpine is a lightweight container. Create the container and execute it :
|
|
If all goes well, accessing http://localhost will show the message “Welcome to my website!”.