Building your first Go Docker image
A Docker image is the filesystem and configuration of our application and is further used to create Docker containers. There are two ways by which a Docker image can be created, which is either from scratch or from a parent image. In this recipe, we will learn how to create a Docker image from a parent image. This means an image created basically refers to the contents of its parent and subsequent declarations in the Dockerfile
modify the parent image.
Getting ready…
Verify whether Docker
and Docker Machine
are installed by executing the following commands:
$ docker --version Docker version 18.03.0-ce, build 0520e24 $ docker-machine --version docker-machine version 0.14.0, build 89b8332
How to do it…
Create
http-server.go
, where we will create a simple HTTP server that will renderHello World!
browsinghttp://docker-machine-ip:8080
or executingcurl -X GET http://docker-machine-ip:8080
from the command line, as follows:
package main import ( "fmt" "log...