You are browsing a read-only backup copy of Wikitech. The live site can be found at

Blubber/Tutorial/HelloWorld: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>David Caro
(→‎Blubberfile: v4 is not yet supported by the version currently available in the repos (deb stretch-wikimedia main).)
(→‎Blubberfile: replacing v3 with v4. when following this tutorial it took me some time to figure out why I couldn't use v3 with blubberoid until I just tried what happens when I enter v4 and that worked)
Line 7: Line 7:
and exit.
and exit.

<syntaxhighlight lang="yaml">version: v3
<syntaxhighlight lang="yaml">version: v4

Latest revision as of 19:00, 27 May 2021

The standard example for any software is one that can print "Hello World!" to the console.


Here is a Blubberfile that will print "Hello World!" to the console and exit.

version: v4

    entrypoint: [echo, "Hello, world!"]

I have the file above saved as hello-blubber.yaml. To generate a Dockerfile from hello-blubber.yaml I pass the blubber command line application two arguments: (1) the path to the hello-blubber.yaml file and (2) the name of the variant (from the keys listed under variants) from which I would like to generate a Dockerfile. In this case hello-blubber.yaml only has one variant named hello.

Dockerfile from Blubberfile

developer@laptop:~/blubber-tutorial$ blubber hello-blubber.yaml hello

This command produces the following Dockerfile on stdout (the output you see may vary depending on your version of blubber):

USER "root"
ENV HOME="/root"
RUN groupadd -o -g "65533" -r "somebody" && useradd -o -m -d "/home/somebody" -r -g "somebody" -u "65533" "somebody" && mkdir -p "/srv/app" && chown "65533":"65533" "/srv/app" && mkdir -p "/opt/lib" && chown "65533":"65533" "/opt/lib"
RUN groupadd -o -g "900" -r "runuser" && useradd -o -m -d "/home/runuser" -r -g "runuser" -u "900" "runuser"
USER "somebody"
ENV HOME="/home/somebody"
WORKDIR "/srv/app"
USER "runuser"
ENV HOME="/home/runuser"
ENTRYPOINT ["echo", "Hello, world!"]
LABEL blubber.variant="hello" blubber.version="0.4.0+60add2d"

Blubber's only purpose is to create opinionated Dockerfiles. To generate a Dockerfile from a Blubberfile you pass the blubber command line program the path to a Blubberfile and a variant name.

Variants can be named anything, although it is common to have (at minimum) a test variant that creates a Dockerfile for an image that runs a test entrypoint, and a production variant that creates a Dockerfile to build an image that can be run in production. To create a Docker Image from this Dockerfile, you can use unix pipes to pipe the output of Blubber to the input of the docker build command.

Build a Variant Image

developer@laptop:~/blubber-tutorial$ blubber hello-blubber.yaml hello | docker build --tag blubber-tutorial-hello-world --file - .

The command above creates a local Docker Image tagged with the name blubber-tutorial-hello-world. Using - as the file tells docker build to use stdin as the Dockerfile. . at the end of the command tells docker build to use the current directory as the context for any copy commands.

Run a Docker Image

To run this image issue the following command:

developer@laptop:~/blubber-tutorial$ docker run --rm --interactive --tty blubber-tutorial-hello-world:latest
Hello, World!