When using Docker, you will quickly realize that the image using to run a project takes a big capacity. A simple image ubuntu took nearly 200MB, but you don’t take full advantage of its available tools. Other images like Node, Go, etc almost run in Ubuntu, debian and only set up more environments to easily deploy. However, downloading a new image takes more time because of its big capacity and it seems to be not necessary at all.
So, I found an empty image :D, except some added metadata by Docker.
docker pull scratch
Therefore, I can say this is the Docker image having the smallest capacity.
docker run --rm -it -v "$GOPATH":/go -e "GOPATH=/go" -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) golang bash
--rmwill delete container after exit,
-v "$GOPATH":/goshare directory GOPATH to container,
-e "GOPATH=/go", -v /var/run/docker.sock:/var/run/docker.sockis used to run Docker into container (docker in docker).
-v $(which docker):$(which docker)is used to share command docker, golang is image environment to build Go binary and build image, bash to begin Bash session.
# scratch FROM scratch WORKDIR /web # copy binary into image COPY web web # copy other necessary files COPY conf conf COPY static static COPY views views EXPOSE 8080 ENTRYPOINT ["/web/web"]
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o web .
docker build -t beego-web .
Drop us a message if you need any helps from the DwarvesLet's build something