How to do it...

Login into an EC2 instance and execute the docker run command to create and run a Docker container from arpitaggarwal/golang-image, assigning the container name as golang-container, using the --name flag, as follows:

$ docker run -d -p 80:8080 --name golang-container -it arpitaggarwal/golang-image 8a9256fcbffc505ad9406f5a8b42ae33ab3951fffb791502cfe3ada42aff781e

The -d flag specified in the docker run command starts the container in a daemon mode and the hash string at the end represents the ID of the golang-container. The -p flag specified in the docker run command publishes a container's port(s) to the host. As we have an HTTP server running on port 8080 inside a Docker container and we opened port 80 for inbound traffic ...

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.