Building a Container that Loops

From NovaOrdis Knowledge Base
Revision as of 03:33, 18 January 2018 by Ovidiu (talk | contribs) (→‎Procedure)
Jump to navigation Jump to search

Internal

Overview

This is a simple container based on centos base image whose command sleep-loos, allowing the container to "hang around" without doing much. It also carry a "probe" script that can be exercised externally.

Procedure

Place the scripts (loop and probe) in an empty directory that will serve as build context.

loop:

#!/bin/sh

while true; do sleep 1s; done

probe:

#!/bin/sh

echo "executed in $(uname -n)"

Dockerfile:

 FROM centos:latest
 COPY loop probe /opt
 CMD /opt/loop

The build command:

cd workarea
docker build -t centos-loop:1 .

The image thus created can be listed in the local registry:

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
centos-loop         1                   89c2ce131758        About a minute ago   207MB
centos              latest              ff426288ea90        9 days ago           207MB