Build operating system image

Follow this process to build a Linux® operating system image for use in a docker container.

About this task: This topic describes a procedure for working with a Debian image.

Before you begin:

You must have Docker installed and running.

  1. Make a directory with a name that relates to your image.
    For example, a directory called debian may contain a Dockerfile for your Debian® image.
    mkdir debian
  2. With a text editor create the file as shown, and save it as Dockerfile.
    FROM debian:latest
    RUN apt-get update \
      && apt-get install -y --no-install-recommends --no-install-suggests \
           file \
           bzip2 \
           binutils \
           sqlite3 \
           sudo \
       && apt-get clean \
       && rm -rf /var/lib/apt/lists/*
    
       ARG user=genero
       ARG group=fourjs
       ARG uid=2000
       ARG gid=2000
    
       ENV HOME=/home/${user}
    
    RUN set -eufx \
      && groupadd -g "${gid}" "${group}" \
      && useradd -d "${HOME}" -u "${uid}" -g "${gid}" -M -N -r -s /bin/bash "${user}" \
      && mkdir -p "${HOME}" \
      && chown "${user}:${group}" "${HOME}" \
     WORKDIR ${HOME}
     USER ${user}
    The docker file contains all the commands needed to get the latest updates and build the Debian image. The user ("genero") and group ("fourjs") are added. A home directory and environment is set up for the user.
    Note:

    The Dockerfile file is written following specific Dockerfile instructions. For more information see the Docker documentation.

  3. At the command line, type the following commands to build the image from your Dockerfile:
    docker pull debian:latest
    docker build --force-rm -t fglgws-os .

    The docker pull command pulls a pre-built Debian image from the Docker repository. The docker build command builds an image called fglgws-os based on the Dockerfile found in the current directory, represented by the dot (.).

  4. Get a list of docker images.
    docker images
    Your docker image (fglgws-os) is shown in the list.
What to do next:

Based on this image, you can now build a docker image with an FGLGWS package. See Build docker image with FGLGWS package