Customize Docker Container Based on Intel® Built Containers

ID 679723
Updated 9/28/2021
Version Latest
Public

author-image

By

Intel® build many docker containers including software & tools contributed by Intel® and publish them in https://hub.docker.com/. It’s easy to search them by keyword “intel”.

Problem:

  1. The containers only include the minimize software scope, even if we miss ‘vim’, ‘ifconfig’ and ‘numactl’. In most cases, we need to install them when using the containers.
  2. In Ubuntu* based containers, the default APT source is official source. The access speed by internet would be slow in some place. We need to add the APT mirror source in local.
  3. If we use such containers at office, we need to set the http/https proxy in container to access internet. We need to set the proxy environment variables in container.

Solution:

To build customized Docker container based on Intel® built could resolve above issues. We will get a good Docker container that includes both Intel® software & tool and our features.

How to do:

Here, we use Intel® container: intel/language-translation:tf-2.4.0-transformer-mlperf-fp32-training as example.

  1. Create a Dockerfile
    from intel/language-translation:tf-2.4.0-transformer-mlperf-fp32-training
    ENV HTTP_PROXY=${HTTP_PROXY}
    ENV HTTPS_PROXY=${HTTPS_PROXY}
    ENV http_proxy=${http_proxy}
    ENV https_proxy=${https_proxy}
    COPY sources.list /etc/apt/
    RUN apt-get update && apt-get install -y vim net-tools numactl
    RUN echo "Done"
    CMD ["/bin/bash"]
  2. Prepare APT Source File
    Create file sources.list in same folder of Dockerfile, add content (Mirror source is for Ubuntu* 20.4 and China) as following:
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse

     

  3. Build the container
    docker_name=my-tf-2.4.0-transformer-mlperf-fp32-training
    docker build . -t $docker_name --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy

     

  4. Run container
    docker_name= my-tf-2.4.0-transformer-mlperf-fp32-training
    docker stop $docker_name
    docker rm $docker_name
    docker run -it --name $docker_name --env http_proxy=$http_proxy --env https_proxy=$https_proxy $docker_name:latest /bin/bash

So that, the new container will include tools: vim, ifconfig and numactl, support http/https proxy to access internet and APT will use local mirror source to speed up the installation.

More important, with the powerful container, it’s easy to enjoy the Intel® contributed software & tool.