本文主要记录从Building ACRN in Docker一文中,学到的docker用法。

Build the Docker Image from Dockerfile

  1. Download Dockerfile to your development machine.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    # Build container based on Clearlinux
    FROM clearlinux:base

    # Tools (bundles) to build the ACRN hypervisor, Device Model, tools and doc
    # - bundles needed to build kernels: bc, lz4, diffutils and devpkg-elfutils, devpkg-ncurses
    # - bundles needed to build the documentation: doxygen, graphviz, desktop-apps
    RUN swupd update -b && \
    swupd bundle-add -b c-basic \
    python3-basic \
    which \
    git \
    devpkg-systemd \
    devpkg-telemetrics-client \
    devpkg-e2fsprogs \
    devpkg-libxml2 \
    devpkg-openssl \
    devpkg-util-linux \
    devpkg-libevent \
    devpkg-libusb \
    devpkg-libpciaccess \
    devpkg-gnu-efi \
    devpkg-numactl \
    bc \
    lz4 \
    diffutils \
    devpkg-elfutils \
    doxygen \
    rsync \
    devpkg-ncurses \
    devpkg-graphviz \
    desktop-apps \
    && rm -rf /var/lib/swupd/*

    RUN pip3 install kconfiglib
    # End of section installing build tools (bundles)

    # Additional tools (Python) to build the documentation
    RUN curl -O https://raw.githubusercontent.com/projectacrn/acrn-hypervisor/master/doc/scripts/requirements.txt && \
    pip3 install -r requirements.txt && \
    rm requirements.txt
    # End of documentation generation tools

    WORKDIR /workspace
  2. Build the Docker image:

不要将Dockerfile文件放到/home/***/目录下。

1
docker build -t clearlinux-acrn-builder:latest -f <path/to/Dockerfile> .

if you are behind an HTTP or HTTPS proxy server, use this command instead:

1
2
3
docker build --build-arg HTTP_PROXY=http://<proxy_host>:<proxy_port> \
--build-arg HTTPS_PROXY=https://<proxy_host>:<proxy_port> \
-t clearlinux-acrn-builder:latest -f <path/to/Dockerfile> .

Build ACRN from Source in Docker

  1. Clone the acrn-hypervisor repo:

    1
    2
    3
    mkdir -p ~/workspace && cd ~/workspace
    git clone https://github.com/projectacrn/acrn-hypervisor
    cd acrn-hypervisor
  2. Build the acrn-hypervisor with the default configuration

    1
    2
    docker run -u`id -u`:`id -g` --rm -v $PWD:/workspace \
    clearlinux-acrn-builder:latest bash -c "make clean && make"