Running your first Go Docker container
A Docker container includes an application and all of its dependencies. It shares the kernel with other containers and runs as an isolated process in the user space on the host operating system. To run the actual application, we have to create and run the containers from an image, which we will be covering in this recipe.
How to do it…
Execute the docker run
command to create and run a Docker container from the golang-image
, assigning the container name as golang-container
using the -name
flag, as follows:
$ docker run -d -p 8080:8080 --name golang-container -it golang-image 9eb53d8d41a237ac216c9bb0f76b4b47d2747fab690569ef6ff4b216e6aab486
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
.
How it works…
Verify whether the Docker container has been created and is running successfully by executing the following command:
$ docker ps
Once the preceding command...