Skip to content

Instantly share code, notes, and snippets.

@d68fbe50
Forked from FreddieOliveira/docker.md
Created June 17, 2022 03:30
Show Gist options
  • Save d68fbe50/1f0eebf015ee7b82e19b2a821eee99c1 to your computer and use it in GitHub Desktop.
Save d68fbe50/1f0eebf015ee7b82e19b2a821eee99c1 to your computer and use it in GitHub Desktop.

Revisions

  1. @FreddieOliveira FreddieOliveira revised this gist Mar 24, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -653,7 +653,10 @@ diff --git a/kernel/Makefile b/kernel/Makefile
    index d5c1115..2dea801 100644
    --- a/kernel/Makefile
    +++ b/kernel/Makefile
    @@ -121,7 +121,7 @@ $(obj)/configs.o: $(obj)/config_data.h # config_data.h contains the same information as ikconfig.h but gzipped. # Info from config_data can be extracted from /proc/config* targets += config_data.gz
    @@ -121,7 +121,7 @@ $(obj)/configs.o: $(obj)/config_data.h
    # config_data.h contains the same information as ikconfig.h but gzipped.
    # Info from config_data can be extracted from /proc/config*
    targets += config_data.gz
    -$(obj)/config_data.gz: arch/arm64/configs/lavender_stock-defconfig FORCE
    +$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
    $(call if_changed,gzip)
  2. @FreddieOliveira FreddieOliveira revised this gist Mar 24, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -655,8 +655,10 @@ index d5c1115..2dea801 100644
    +++ b/kernel/Makefile
    @@ -121,7 +121,7 @@ $(obj)/configs.o: $(obj)/config_data.h # config_data.h contains the same information as ikconfig.h but gzipped. # Info from config_data can be extracted from /proc/config* targets += config_data.gz
    -$(obj)/config_data.gz: arch/arm64/configs/lavender_stock-defconfig FORCE
    +$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE $(call if_changed,gzip) filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/basic/bin2c; echo "MAGIC_END;")
    +$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
    $(call if_changed,gzip)

    filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/basic/bin2c; echo "MAGIC_END;")
    ```

    - net/netfilter/xt_qtaguid.c
  3. @FreddieOliveira FreddieOliveira revised this gist Mar 24, 2021. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -647,6 +647,18 @@ Now, we need to install the i386 version of some libs required by steam. For thi
    ## 4.1. kernel patches

    - kernel/Makefile

    ```patch
    diff --git a/kernel/Makefile b/kernel/Makefile
    index d5c1115..2dea801 100644
    --- a/kernel/Makefile
    +++ b/kernel/Makefile
    @@ -121,7 +121,7 @@ $(obj)/configs.o: $(obj)/config_data.h # config_data.h contains the same information as ikconfig.h but gzipped. # Info from config_data can be extracted from /proc/config* targets += config_data.gz
    -$(obj)/config_data.gz: arch/arm64/configs/lavender_stock-defconfig FORCE
    +$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE $(call if_changed,gzip) filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/basic/bin2c; echo "MAGIC_END;")

    ```

    - net/netfilter/xt_qtaguid.c

    ```patch
  4. @FreddieOliveira FreddieOliveira revised this gist Mar 22, 2021. No changes.
  5. @FreddieOliveira FreddieOliveira revised this gist Feb 19, 2021. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -112,7 +112,7 @@ Don't worry though, this is a harmless warning remembering you that you're using

    ## 2.3. Docker

    See [Edit](#edit).
    See [Edit](#edit-).

    Once you have a supported kernel, it's time to compile the docker suite. It's a suite because it's not just one program, but rather a set of different programs that we'll need to compile separately. So hands on.

    @@ -133,7 +133,7 @@ Download all the patches files into there and let's begin. All commands for the

    ### 2.3.1. dockercli

    See [Edit](#edit).
    See [Edit](#edit-).

    This is the docker client, which will talk to the docker daemon. This package will compile a binary named `docker` and all docker man pages. To build and install it:

    @@ -162,7 +162,7 @@ $ install -Dm 600 -t $PREFIX/share/man/man8 man/man8/*

    ### 2.3.2. dockerd

    See [Edit](#edit).
    See [Edit](#edit-).

    The docker daemon is the most problematic binary that's gonna be compiled. It needs so many patches that's easier to modify the code in a batch with sed. Despite the need of modifying a lot of files, the modifications by themselfs are rather simple:

    @@ -268,7 +268,7 @@ $ ln -s $PREFIX/bin/tini-static $PREFIX/bin/docker-init

    ### 2.3.4. libnetwork

    See [Edit](#edit).
    See [Edit](#edit-).

    Another dockerd dependency needed when using the `-p` flag while creating a container:

    @@ -287,7 +287,7 @@ $ install -Dm 0700 docker-proxy $PREFIX/bin/docker-proxy

    ### 2.3.5. containerd

    See [Edit](#edit).
    See [Edit](#edit-).

    This is a dockerd dependency. Some patches are needed to fix path locations, build the manuals correctly and compile extra binaries used by dockerd that are not build by default by the Makefile:

    @@ -339,7 +339,7 @@ EOF
    ### 2.3.6. runc

    See [Edit](#edit).
    See [Edit](#edit-).

    runc is a dependency of containerd. Conveniently for us, it's already provided by Termux's repository. Install it by simply:

  6. @FreddieOliveira FreddieOliveira revised this gist Feb 19, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Docker on Android 🐋📱

    ### ***Edit***
    ### ***Edit*** 🎉

    All packages, except for Tini have been added to [termux-root](https://github.com/termux/termux-root-packages). To install them, simply `pkg install root-repo && pkg install docker`. This will install the whole docker suite, left only Tini to be compiled manually.

  7. @FreddieOliveira FreddieOliveira revised this gist Feb 19, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ### ***Edit***

    All packages, except for Tini have been added to termux-root. To install them, simply `pkg install root-repo && pkg install docker`. This will install the whole docker suite, left only Tini to be compiled manually.
    All packages, except for Tini have been added to [termux-root](https://github.com/termux/termux-root-packages). To install them, simply `pkg install root-repo && pkg install docker`. This will install the whole docker suite, left only Tini to be compiled manually.

    ---

  8. @FreddieOliveira FreddieOliveira revised this gist Feb 19, 2021. 1 changed file with 6 additions and 14 deletions.
    20 changes: 6 additions & 14 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,6 @@

    ### ***Edit***

    Docker packages are in the process of being added to [termux-root repo](https://github.com/termux/termux-root-packages). Soon enough, compiling them by hand won't be necessary anymore 😃

    ### ***Edit 2***

    [containerd](#235-containerd) has been added to termux-root repo already. If desired, just `pkg install root-repo && pkg install containerd` instead of manually build it. **No need to install containerd separately anymore, see edit 3 bellow.**

    ### ***Edit 3***

    All packages, except for Tini have been added to termux-root. To install them, simply `pkg install root-repo && pkg install docker`. This will install the whole docker suite, left only Tini to be compiled manually.

    ---
    @@ -120,7 +112,7 @@ Don't worry though, this is a harmless warning remembering you that you're using

    ## 2.3. Docker

    See [Edit 3](#edit-3).
    See [Edit](#edit).

    Once you have a supported kernel, it's time to compile the docker suite. It's a suite because it's not just one program, but rather a set of different programs that we'll need to compile separately. So hands on.

    @@ -141,7 +133,7 @@ Download all the patches files into there and let's begin. All commands for the

    ### 2.3.1. dockercli

    See [Edit 3](#edit-3).
    See [Edit](#edit).

    This is the docker client, which will talk to the docker daemon. This package will compile a binary named `docker` and all docker man pages. To build and install it:

    @@ -170,7 +162,7 @@ $ install -Dm 600 -t $PREFIX/share/man/man8 man/man8/*

    ### 2.3.2. dockerd

    See [Edit 3](#edit-3).
    See [Edit](#edit).

    The docker daemon is the most problematic binary that's gonna be compiled. It needs so many patches that's easier to modify the code in a batch with sed. Despite the need of modifying a lot of files, the modifications by themselfs are rather simple:

    @@ -276,7 +268,7 @@ $ ln -s $PREFIX/bin/tini-static $PREFIX/bin/docker-init

    ### 2.3.4. libnetwork

    See [Edit 3](#edit-3).
    See [Edit](#edit).

    Another dockerd dependency needed when using the `-p` flag while creating a container:

    @@ -295,7 +287,7 @@ $ install -Dm 0700 docker-proxy $PREFIX/bin/docker-proxy

    ### 2.3.5. containerd

    See [Edit 3](#edit-3).
    See [Edit](#edit).

    This is a dockerd dependency. Some patches are needed to fix path locations, build the manuals correctly and compile extra binaries used by dockerd that are not build by default by the Makefile:

    @@ -347,7 +339,7 @@ EOF
    ### 2.3.6. runc

    See [Edit 3](#edit-3).
    See [Edit](#edit).

    runc is a dependency of containerd. Conveniently for us, it's already provided by Termux's repository. Install it by simply:

  9. @FreddieOliveira FreddieOliveira revised this gist Feb 19, 2021. 1 changed file with 16 additions and 2 deletions.
    18 changes: 16 additions & 2 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,11 @@ Docker packages are in the process of being added to [termux-root repo](https://

    ### ***Edit 2***

    [containerd](#235-containerd) has been added to termux-root repo already. If desired, just `pkg install root-repo && pkg install containerd` instead of manually build it.
    [containerd](#235-containerd) has been added to termux-root repo already. If desired, just `pkg install root-repo && pkg install containerd` instead of manually build it. **No need to install containerd separately anymore, see edit 3 bellow.**

    ### ***Edit 3***

    All packages, except for Tini have been added to termux-root. To install them, simply `pkg install root-repo && pkg install docker`. This will install the whole docker suite, left only Tini to be compiled manually.

    ---

    @@ -116,6 +120,8 @@ Don't worry though, this is a harmless warning remembering you that you're using

    ## 2.3. Docker

    See [Edit 3](#edit-3).

    Once you have a supported kernel, it's time to compile the docker suite. It's a suite because it's not just one program, but rather a set of different programs that we'll need to compile separately. So hands on.

    Firts, let's install the packages we're gonna use to build docker in Termux:
    @@ -135,6 +141,8 @@ Download all the patches files into there and let's begin. All commands for the

    ### 2.3.1. dockercli

    See [Edit 3](#edit-3).

    This is the docker client, which will talk to the docker daemon. This package will compile a binary named `docker` and all docker man pages. To build and install it:

    ```
    @@ -162,6 +170,8 @@ $ install -Dm 600 -t $PREFIX/share/man/man8 man/man8/*

    ### 2.3.2. dockerd

    See [Edit 3](#edit-3).

    The docker daemon is the most problematic binary that's gonna be compiled. It needs so many patches that's easier to modify the code in a batch with sed. Despite the need of modifying a lot of files, the modifications by themselfs are rather simple:

    1. Substitute every occurrence of `runtime.GOOS` by the string `"linux"`;
    @@ -266,6 +276,8 @@ $ ln -s $PREFIX/bin/tini-static $PREFIX/bin/docker-init

    ### 2.3.4. libnetwork

    See [Edit 3](#edit-3).

    Another dockerd dependency needed when using the `-p` flag while creating a container:

    ```
    @@ -283,7 +295,7 @@ $ install -Dm 0700 docker-proxy $PREFIX/bin/docker-proxy

    ### 2.3.5. containerd

    See [Edit 2](#edit-2).
    See [Edit 3](#edit-3).

    This is a dockerd dependency. Some patches are needed to fix path locations, build the manuals correctly and compile extra binaries used by dockerd that are not build by default by the Makefile:

    @@ -335,6 +347,8 @@ EOF
    ### 2.3.6. runc

    See [Edit 3](#edit-3).

    runc is a dependency of containerd. Conveniently for us, it's already provided by Termux's repository. Install it by simply:

    ```
  10. @FreddieOliveira FreddieOliveira revised this gist Feb 16, 2021. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -604,12 +604,9 @@ $ sudo docker run -ti \
    arm32v7/ubuntu
    ```

    > **Note:** if your system is already 32 bit (run `uname -m` to
    check), you don't need to specify the `--platform=linux/arm` flag
    and can simply use `ubuntu` instead of `arm32v7/ubuntu`.
    > **Note:** if your system is 32 bit already (run `uname -m` to check), you don't need to specify the `--platform=linux/arm` flag and can simply use `ubuntu` instead of `arm32v7/ubuntu`.
    Now that we are inside the container, let's install the tools we're
    gonna use, as well as the steam .deb installer:
    Now that we are inside the container, let's install the tools we're gonna use, as well as the steam .deb installer:

    ```
    # echo 'APT::Sandbox::User root;' >> /etc/apt/apt.conf
  11. @FreddieOliveira FreddieOliveira revised this gist Feb 16, 2021. 1 changed file with 30 additions and 18 deletions.
    48 changes: 30 additions & 18 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -588,7 +588,7 @@ I'm not talking about running the useless steam app for Android, but about runni

    To do so, we'll use an awesome x86 emulator for ARM developed by @ptitSeb called [box86](https://github.com/ptitSeb/box86).

    But first, you need to enable `System V IPC` under `General Setup` in the kernel config and recompile it again. That's because the steam binary uses some semaphore functions and will crash in case it can't use them.
    But first, you need to enable `System V IPC` under `General Setup` in the kernel config and recompile it again. That's because the steam binary needs some semaphore functions and will crash in case it can't use them.

    Next, we hit a problem: box86 can only be compiled by a 32 bit toolchain. But, in fact, this can be easily circumvented by using a 32 bit container:

    @@ -604,28 +604,40 @@ $ sudo docker run -ti \
    arm32v7/ubuntu
    ```

    > **Note:** if your system is 32 bit already (run `uname -m` to check), you don't need to specify the `--platform=linux/arm` flag and can simply use `ubuntu` instead of `arm32v7/ubuntu`.
    > **Note:** if your system is already 32 bit (run `uname -m` to
    check), you don't need to specify the `--platform=linux/arm` flag
    and can simply use `ubuntu` instead of `arm32v7/ubuntu`.

    Now that we are inside the container, let's install the tools we're gonna use, as well as the steam .deb installer:
    Now that we are inside the container, let's install the tools we're
    gonna use, as well as the steam .deb installer:

    ```
    # echo 'APT::Sandbox::User "root";' > /etc/apt/apt.conf
    # echo 'APT::Sandbox::User root;' >> /etc/apt/apt.conf
    # apt update
    # apt install wget libvdpau1 libappindicator1 libnm0 libdbusmenu-gtk4
    # apt install wget binutils xterm libvdpau1 libappindicator1 libnm0 libdbusmenu-gtk4
    ```

    Install steam:

    ```
    # wget https://steamcdn-a.akamaihd.net/client/installer/steam.deb
    # tar tf data.tar.xz \
    | grep -v ".*\/$" \
    | grep -o "[^\.].*\/" \
    | uniq \
    | while read folder; do
    mkdir -p $folder;
    done
    ```

    wget http://mirrors.kernel.org/ubuntu/pool/universe/libv/libva/libva2_2.7.0-2_i386.deb
    wget
    LIBGL: Cannot use eglCopyBuffers, disabling it's use: LIBGL: ERROR: EGL Error detected: EGL_BAD_NATIVE_PIXMAP
    LIBGL: ERROR: EGL Error detected: EGL_BAD_CONTEXT
    # ar x steam.deb
    # mkdir steam
    # tar xf data.tar.xz -C steam
    # find steam -type d -exec sh -c 'mkdir -p /${0#*/}' {} \;
    # find steam \! -type d -exec sh -c 'mv $0 /${0#*/}' {} \;
    # patch /usr/lib/steam/bin_steam.sh bin_steam.sh.patch
    # rm -rf steam* *.tar* bin_steam.sh.patch
    # steam
    ```

    Steam will fail with a bunch of errors, but that's expected. The important thing is that it installed the necessary files under `~/.local/share/Steam`, one of them being the steam binary. Finish the installation by adding it to the path:

    ```
    # ln -sf /root/.local/share/Steam/ubuntu12_32/steam /usr/bin/steam
    ```

    Now, we need to install the i386 version of some libs required by steam. For this, we're going to download them directly from Ubuntu packages. That's because if we instead simply apt install them we would be getting the arm32 version.

    # 4. Attachments

  12. @FreddieOliveira FreddieOliveira revised this gist Feb 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -372,7 +372,7 @@ The two [network drivers](https://docs.docker.com/network/) tested so far are `b

    #### bridge

    This is the default netwok driver. If you don't specify a driver, this is the type of network you are creating. [Bridge networks](https://docs.docker.com/network/bridge/) isolates the container network by creating a network interface called `Docker0` that serves as a bridge and editing the iptables rules. All containers created with the bridge driver will use this interface. This is analogous to creating a VLAN and running the containers inside it.
    This is the default netwok driver. If you don't specify a driver, this is the type of network you are creating. [Bridge networks](https://docs.docker.com/network/bridge/) isolate the container network by editing the iptables rules and creating a network interface called `Docker0` that serves as a bridge. All containers created with the bridge driver will use this interface. This is analogous to creating a VLAN and running the containers inside it.

    But, there's a catch in Android: iptables rules policy is different here than on a conventional GNU/Linux system (more info [here](https://gist.github.com/FreddieOliveira/efe850df7ff3951cb62d74bd770dce27#gistcomment-3605349)). For the bridge driver to work, you'll have to manually edit the iptable by running;

  13. @FreddieOliveira FreddieOliveira revised this gist Feb 14, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -16,9 +16,9 @@ Docker packages are in the process of being added to [termux-root repo](https://
    2. [Building](#2-building)
    1. [Rooting](#21-rooting)
    2. [Kernel](#22-kernel)
    1. [General compiling instructions](#221-general-compiling-instructions)
    2. [Modifications](#222-modifications)
    3. [Patching](#223-patching)
    1. [General compiling instructions](#221-general-compiling-instructions)
    2. [Modifications](#222-modifications)
    3. [Patching](#223-patching)
    3. [Docker](#23-docker)
    1. [dockercli](#231-dockercli)
    2. [dockerd](#232-dockerd)
  14. @FreddieOliveira FreddieOliveira revised this gist Feb 2, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -178,6 +178,7 @@ $ tar xf moby-20.10.2.tar.gz
    $ cd moby-20.10.2
    $ export DOCKER_GITCOMMIT=8891c58a43
    $ export DOCKER_BUILDTAGS='exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_quota selinux exclude_graphdriver_aufs'
    $ patch cmd/dockerd/daemon.go ../daemon.go.patch
    $ xargs sed -i "s_\(/etc/docker\)_$PREFIX\1_g" < <(grep -R /etc/docker | cut -d':' -f1 | sort | uniq)
    $ xargs sed -i 's_\(/run/docker/plugins\)_/data/docker\1_g' < <(grep -R '/run/docker/plugins' | cut -d':' -f1 | sort | uniq)
    $ xargs sed -i 's/[a-zA-Z0-9]*\.GOOS/"linux"/g' < <(grep -R '[a-zA-Z0-9]*\.GOOS' | cut -d':' -f1 | sort | uniq)
  15. @FreddieOliveira FreddieOliveira revised this gist Feb 2, 2021. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -320,6 +320,13 @@ imports = ["$PREFIX/etc/containerd/runtime_*.toml", "./debug.toml"]
    [debug]
    address = "/data/docker/run/containerd/debug.sock"
    [plugins]
    [plugins.opt]
    path = "/data/docker/opt"
    [plugins.cri.cni]
    bin_dir = "/data/docker/opt/cni/bin"
    conf_dir = "/data/docker/etc/cni/net.d"
    EOF
    ```

  16. @FreddieOliveira FreddieOliveira revised this gist Feb 2, 2021. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,8 @@ Docker packages are in the process of being added to [termux-root repo](https://
    4. [Attachments](#4-attachments)
    1. [Kernel patches](#41-kernel-patches)
    2. [docker-cli patches](#42-docker-cli-patches)
    3. [containerd patches](#43-containerd-patches)
    3. [dockerd patches](#43-dockerd-patches)
    4. [containerd patches](#44-containerd-patches)
    5. [Aknowledgements ](#5-aknowledgements)
    6. [Final notes](#6-final-notes)

    @@ -657,7 +658,10 @@ LIBGL: ERROR: EGL Error detected: EGL_BAD_CONTEXT
    - [man/md2man-all.sh](https://github.com/termux/termux-root-packages/files/5793952/md2man-all.sh.patch.txt)
    - [cli/config/config.go](https://github.com/termux/termux-root-packages/files/5793948/config.go.patch.txt)

    ## 4.3. containerd patches
    ## 4.3. dockerd patches
    - [cmd/dockerd/daemon.go](https://raw.githubusercontent.com/termux/termux-root-packages/29ca852ba95ae76b03189adbf68309fc217be7dd/packages/docker/daemon.go.patch)

    ## 4.4. containerd patches

    - [runtime/v1/linux/bundle.go](https://github.com/termux/termux-root-packages/files/5793939/bundle.go.patch.txt)
    - [runtime/v2/shim/util_unix.go](https://github.com/termux/termux-root-packages/files/5793946/util_unix.go.patch.txt)
  17. @FreddieOliveira FreddieOliveira revised this gist Feb 2, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -178,6 +178,7 @@ $ cd moby-20.10.2
    $ export DOCKER_GITCOMMIT=8891c58a43
    $ export DOCKER_BUILDTAGS='exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_quota selinux exclude_graphdriver_aufs'
    $ xargs sed -i "s_\(/etc/docker\)_$PREFIX\1_g" < <(grep -R /etc/docker | cut -d':' -f1 | sort | uniq)
    $ xargs sed -i 's_\(/run/docker/plugins\)_/data/docker\1_g' < <(grep -R '/run/docker/plugins' | cut -d':' -f1 | sort | uniq)
    $ xargs sed -i 's/[a-zA-Z0-9]*\.GOOS/"linux"/g' < <(grep -R '[a-zA-Z0-9]*\.GOOS' | cut -d':' -f1 | sort | uniq)
    $ (while ! IFS='' files=$(AUTO_GOPATH=1 PREFIX='' hack/make.sh dynbinary 2>&1 1>/dev/null); do if ! xargs sed -i 's/\("runtime"\)/_ \1/' < <(echo $files | grep runtime | cut -d':' -f1 | cut -c38-); then echo $files; exit 1; fi; done)
    $ install -Dm 0700 bundles/dynbinary-daemon/dockerd $PREFIX/bin/dockerd-dev
  18. @FreddieOliveira FreddieOliveira revised this gist Feb 1, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -385,7 +385,7 @@ To use this driver give the `--net=host --dns=8.8.8.8` flags when running a cont

    An easy way to share folders and files between containers and the host is to use a shared volume. For example, using the `-v ~/Documents/docker-share:/root/docker-share` flag when running a container, will make the `~/Documents/docker-share` folder from the host to be accessible inside the container `/root/docker-share` folder.

    But, when talking about Android, things seems to never be as easy and straightforward as expected. Due to Android file system encryption, if you `ls` the `/root/docker-share` folder inside the container you'll might see a bunch of random letters and numbers instead of the folders and files names:
    But, when talking about Android, things seems to never be as easy and straightforward as expected. Due to Android file system encryption, if you `ls` the `/root/docker-share` folder inside the container you might see a bunch of random letters, numbers and symbols instead of the folders and files names:

    ```
    # ls /root/docker-share
  19. @FreddieOliveira FreddieOliveira revised this gist Feb 1, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Docker packages are in the process of being added to [termux-root repo](https://

    ### ***Edit 2***

    [containerd](#235-containerd) has been added to termux-root repo already. If desired, just `pkg install containerd` instead of manually build it.
    [containerd](#235-containerd) has been added to termux-root repo already. If desired, just `pkg install root-repo && pkg install containerd` instead of manually build it.

    ---

  20. @FreddieOliveira FreddieOliveira revised this gist Feb 1, 2021. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,8 @@ Docker packages are in the process of being added to [termux-root repo](https://
    6. [runc](#236-runc)
    3. [Running](#3-running)
    1. [Caveats](#31-caveats)
    1. [Internet access](#311-internet-access)
    2. [Shared volumes](#312-shared-volumes)
    2. [GUI](#32-gui)
    1. [X11 Forwarding](#321-x11-forwarding)
    2. [VNC server within the container](#322-vnc-server-within-the-container)
    @@ -381,7 +383,9 @@ To use this driver give the `--net=host --dns=8.8.8.8` flags when running a cont

    ### 3.1.2. Shared volumes

    An easy way to share folders and files between containers and the host is to use a shared volume. For example, using the `-v $TMPDIR/docker-share:/root/docker-share` flag when running a container, will make the `~/Documents/docker-share` folder from the host to be accessible inside the container `/root/docker-share` folder. But, when talking about Android, things seems to never be as easy and straightforward as expected. Due to Android file system encryption, if you `ls` the `/root/docker-share` folder inside the container you'll might see a bunch of random letters and numbers instead of the folders and files names:
    An easy way to share folders and files between containers and the host is to use a shared volume. For example, using the `-v ~/Documents/docker-share:/root/docker-share` flag when running a container, will make the `~/Documents/docker-share` folder from the host to be accessible inside the container `/root/docker-share` folder.

    But, when talking about Android, things seems to never be as easy and straightforward as expected. Due to Android file system encryption, if you `ls` the `/root/docker-share` folder inside the container you'll might see a bunch of random letters and numbers instead of the folders and files names:

    ```
    # ls /root/docker-share
  21. @FreddieOliveira FreddieOliveira revised this gist Feb 1, 2021. 1 changed file with 61 additions and 5 deletions.
    66 changes: 61 additions & 5 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -118,7 +118,7 @@ Once you have a supported kernel, it's time to compile the docker suite. It's a
    Firts, let's install the packages we're gonna use to build docker in Termux:

    ```
    $ pkg install golang make ndk-multilib
    $ pkg install go make cmake ndk-multilib tsu
    ```

    Now we're ready to start compiling things. Create a work directory where the packages will be downloaded and built:
    @@ -135,6 +135,7 @@ Download all the patches files into there and let's begin. All commands for the
    This is the docker client, which will talk to the docker daemon. This package will compile a binary named `docker` and all docker man pages. To build and install it:

    ```
    $ cd $TMPDIR/docker-build
    $ wget https://github.com/docker/cli/archive/v20.10.2.tar.gz -O cli-20.10.2.tar.gz
    $ tar xf cli-20.10.2.tar.gz
    $ mkdir -p src/github.com/docker
    @@ -168,6 +169,7 @@ By doing that, we are in essence spoofing our operating system as a Linux one: e
    To make the substitution across every file, we'll run a sed command. After that, some files will now give the extremely annoying unturnable-off go lang "feature" `imported and not used` error, because the only function these files were using from the `runtime` package was the `runtime.GOOS`. So, to fix it we'll use an horrible but simple solution: we'll keep trying to compile the code and at each failed attempt we'll fix the reported files till we get it to compile successfully.

    ```
    $ cd $TMPDIR/docker-build
    $ wget https://github.com/moby/moby/archive/v20.10.2.tar.gz -O moby-20.10.2.tar.gz
    $ tar xf moby-20.10.2.tar.gz
    $ cd moby-20.10.2
    @@ -176,7 +178,7 @@ $ export DOCKER_BUILDTAGS='exclude_graphdriver_btrfs exclude_graphdriver_devicem
    $ xargs sed -i "s_\(/etc/docker\)_$PREFIX\1_g" < <(grep -R /etc/docker | cut -d':' -f1 | sort | uniq)
    $ xargs sed -i 's/[a-zA-Z0-9]*\.GOOS/"linux"/g' < <(grep -R '[a-zA-Z0-9]*\.GOOS' | cut -d':' -f1 | sort | uniq)
    $ (while ! IFS='' files=$(AUTO_GOPATH=1 PREFIX='' hack/make.sh dynbinary 2>&1 1>/dev/null); do if ! xargs sed -i 's/\("runtime"\)/_ \1/' < <(echo $files | grep runtime | cut -d':' -f1 | cut -c38-); then echo $files; exit 1; fi; done)
    $ install -Dm 0700 bundles/dynbinary-daemon/dockerd-dev $PREFIX/bin/dockerd-dev
    $ install -Dm 0700 bundles/dynbinary-daemon/dockerd $PREFIX/bin/dockerd-dev
    ```

    A binary called dockerd-dev was compiled and installed, but in order to it run correctly, the cgroups need to be mounted. Since Android mounts the cgroups in a non standard location we need to fix this. To do so, a script named dockerd will be created that will mount crgoups in the correct path if needed and call dockerd-dev next.
    @@ -211,7 +213,7 @@ for cg in ${cgroups}; do
    done
    # start the docker daemon
    dockerd-dev $@
    $PREFIX/bin/dockerd-dev $@
    EOF
    ```

    @@ -245,11 +247,12 @@ EOF
    tini is an optional dependency of dockerd in case you want the `init` process to be the first process of the container being ran (for this use the `--init` flag when creating a container). Having `init` as the parent of all other proccess ensures that a proper clean up inside the container is made regarding zombie processes. For a detailed explanation on its benefits and when to use it, check here: https://github.com/krallin/tini/issues/8

    ```
    $ cd $TMPDIR/docker-build
    $ wget https://github.com/krallin/tini/archive/v0.19.0.tar.gz
    $ tar xf v0.19.0.tar.gz
    $ cd tini-0.19.0
    $ mkdir build
    $ cd buid
    $ cd build
    $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX ..
    $ make -j8
    $ make install
    @@ -261,6 +264,7 @@ $ ln -s $PREFIX/bin/tini-static $PREFIX/bin/docker-init
    Another dockerd dependency needed when using the `-p` flag while creating a container:

    ```
    $ cd $TMPDIR/docker-build
    $ wget https://github.com/moby/libnetwork/archive/448016ef11309bd67541dcf4d72f1f5b7de94862.tar.gz
    $ tar xf 448016ef11309bd67541dcf4d72f1f5b7de94862.tar.gz
    $ mkdir -p src/github.com/docker
    @@ -279,6 +283,7 @@ See [Edit 2](#edit-2).
    This is a dockerd dependency. Some patches are needed to fix path locations, build the manuals correctly and compile extra binaries used by dockerd that are not build by default by the Makefile:

    ```
    $ cd $TMPDIR/docker-build
    $ wget https://github.com/containerd/containerd/archive/v1.4.3.tar.gz
    $ tar xf v1.4.3.tar.gz
    $ mkdir -p src/github.com/containerd
    @@ -321,6 +326,7 @@ EOF
    runc is a dependency of containerd. Conveniently for us, it's already provided by Termux's repository. Install it by simply:

    ```
    $ pkg install root-repo
    $ pkg install runc
    ```

    @@ -348,7 +354,55 @@ $ sudo docker run hello-world
    ## 3.1. Caveats

    After months testing docker, the only thing I couldn't managed to get working 100% as intended is the internet. I'm not sure why, but the only way to get the containers to access the internet is to use the `--net=host` flag. Trying to isolate the container network almost work: the tun tap interface is created, but it doesn't seem to work.
    ### 3.1.1. Internet access

    The two [network drivers](https://docs.docker.com/network/) tested so far are `bridge` and `host`. Here's how to get each of them working.

    #### bridge

    This is the default netwok driver. If you don't specify a driver, this is the type of network you are creating. [Bridge networks](https://docs.docker.com/network/bridge/) isolates the container network by creating a network interface called `Docker0` that serves as a bridge and editing the iptables rules. All containers created with the bridge driver will use this interface. This is analogous to creating a VLAN and running the containers inside it.

    But, there's a catch in Android: iptables rules policy is different here than on a conventional GNU/Linux system (more info [here](https://gist.github.com/FreddieOliveira/efe850df7ff3951cb62d74bd770dce27#gistcomment-3605349)). For the bridge driver to work, you'll have to manually edit the iptable by running;

    ```
    $ sudo ip route add default via 192.168.1.1 dev wlan0
    $ sudo ip rule add from all lookup main pref 30000
    ```

    > **Note:** change 192.168.1.1 according to your gateway IP.
    Unfortunately, this means that changing networks will require you to re-configure the rules again.

    #### host

    Using the [host driver](https://docs.docker.com/network/host/), means to remove network isolation between the container and the Docker host, and use the host’s networking directly. This way, the container will use the same network interface as your device (e.g. wlan0) and thus will share the same IP address.

    To use this driver give the `--net=host --dns=8.8.8.8` flags when running a container.

    ### 3.1.2. Shared volumes

    An easy way to share folders and files between containers and the host is to use a shared volume. For example, using the `-v $TMPDIR/docker-share:/root/docker-share` flag when running a container, will make the `~/Documents/docker-share` folder from the host to be accessible inside the container `/root/docker-share` folder. But, when talking about Android, things seems to never be as easy and straightforward as expected. Due to Android file system encryption, if you `ls` the `/root/docker-share` folder inside the container you'll might see a bunch of random letters and numbers instead of the folders and files names:

    ```
    # ls /root/docker-share
    +2xKy7JIRrcGrCf+o6KSeB T6BJkyIa5OedXNrSyRKLbB cwoDh,Nzt1l,5BsKA4hH8D
    2aHRCQEyK8yYiiK9PEI9SA Ue39lJVm4kIxGrS1bV07zB lEpWZhTY9dNqJxCu+GqBuA
    5ZRDLfHMwyik6RMe,f0WPA X+yGLxXSgwxbCsFGRXuczC y4ZWVvVBBjcxSWlJ9conED
    GljgSZK5gFr7D4Fk7BHNeB X1ATNoqhp,,ZsKjFXqKFiA
    I3N5j0R4zmaQPKCWwKBlxD Yzi+KmovJmIYFOCHtDCXkB
    ```

    and if you try to read or create a file inside the volume you might get the `Required key not available` error.

    No [definitive solution](https://gist.github.com/FreddieOliveira/efe850df7ff3951cb62d74bd770dce27#gistcomment-3606119) was discovered so far, but a workaround is to `cat` the files from within the host to give the container temporary access to them. You can cat an individual file by:
    ```
    $ sudo cat ~/Documents/docker-share/file.pdf >/dev/null
    ```
    or all of them by:

    ```
    $ sudo find ~/Documents/docker-share -exec cat {} >/dev/null \;
    ```

    ## 3.2. GUI

    @@ -610,6 +664,8 @@ LIBGL: ERROR: EGL Error detected: EGL_BAD_CONTEXT

    I'd like to thank the Termux Dev team for this wonderful app and @xeffyr for discovering about the bug in `net/netfilter/xt_qtaguid.c` and sharing the patch, as well as all the conversation we had [here](https://github.com/termux/termux-root-packages/issues/60) that led to docker finally working.

    Also @yjwong, for figuring out how to use the bridge network driver.

    # 6. Final notes

    If you are a docker developer reading this, please consider adding an official support for Android. Look above the possibilities it opens for a smartphone. If you are not a docker developer, consider supporting this by showing interest [here](https://github.com/moby/moby/issues/41111). If we annoy the devs enough, this may become official (of they may simply unsubscribe from the thread and let it rot in the Issues section ¯\\_(ツ)\_/¯ ).
  22. @FreddieOliveira FreddieOliveira revised this gist Jan 24, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -242,7 +242,7 @@ EOF
    ### 2.3.3. tini

    tini is an optional dependency of dockerd in case you want the `init` process to be the first process of the container being ran (for this use the `--init` flag when creating a container). Having `init` as the parent of all other proccess ensures that a proper clean up inside the container is made when it exits.
    tini is an optional dependency of dockerd in case you want the `init` process to be the first process of the container being ran (for this use the `--init` flag when creating a container). Having `init` as the parent of all other proccess ensures that a proper clean up inside the container is made regarding zombie processes. For a detailed explanation on its benefits and when to use it, check here: https://github.com/krallin/tini/issues/8

    ```
    $ wget https://github.com/krallin/tini/archive/v0.19.0.tar.gz
  23. @FreddieOliveira FreddieOliveira revised this gist Jan 24, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -263,8 +263,10 @@ Another dockerd dependency needed when using the `-p` flag while creating a cont
    ```
    $ wget https://github.com/moby/libnetwork/archive/448016ef11309bd67541dcf4d72f1f5b7de94862.tar.gz
    $ tar xf 448016ef11309bd67541dcf4d72f1f5b7de94862.tar.gz
    $ mkdir -p src/github.com/docker
    $ mv libnetwork-448016ef11309bd67541dcf4d72f1f5b7de94862 src/github.com/docker/libnetwork
    $ export GOPATH="$(pwd)"
    $ cd libnetwork-448016ef11309bd67541dcf4d72f1f5b7de94862
    $ cd src/github.com/docker/libnetwork
    $ go build -o docker-proxy github.com/docker/libnetwork/cmd/proxy
    $ strip docker-proxy
    $ install -Dm 0700 docker-proxy $PREFIX/bin/docker-proxy
  24. @FreddieOliveira FreddieOliveira revised this gist Jan 24, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -45,7 +45,7 @@ Docker packages are in the process of being added to [termux-root repo](https://

    This tutorial presents a step by step guide on how to run docker containers directly on Android. By directly I mean there's no VM involved nor chrooting inside a GNU/Linux rootfs. This is docker purely in Android. Yes, ***it is*** possible.

    Bear in mind that you'll have to root your phone, mess with and compile your phone's kernel and docker suit. So, be prepared to get your hands dirty.
    Bear in mind that you'll have to root your phone, mess with and compile your phone's kernel and docker suite. So, be prepared to get your hands dirty.

    # 2. Building

    @@ -113,7 +113,7 @@ Don't worry though, this is a harmless warning remembering you that you're using

    ## 2.3. Docker

    Once you have a supported kernel, it's time to compile the docker suit. It's a suit because it's not just one program, but rather a set of different programs that we'll need to compile separately. So hands on.
    Once you have a supported kernel, it's time to compile the docker suite. It's a suite because it's not just one program, but rather a set of different programs that we'll need to compile separately. So hands on.

    Firts, let's install the packages we're gonna use to build docker in Termux:

  25. @FreddieOliveira FreddieOliveira revised this gist Jan 23, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -250,10 +250,10 @@ $ tar xf v0.19.0.tar.gz
    $ cd tini-0.19.0
    $ mkdir build
    $ cd buid
    $ cmake -DCMAKE_BUILD_TYPE=Release ..
    $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX ..
    $ make -j8
    $ install -Dm 0700 tini-static $PREFIX/bin/tini
    $ ln -s $PREFIX/bin/tini $PREFIX/bin/docker-init
    $ make install
    $ ln -s $PREFIX/bin/tini-static $PREFIX/bin/docker-init
    ```

    ### 2.3.4. libnetwork
  26. @FreddieOliveira FreddieOliveira revised this gist Jan 22, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -342,13 +342,13 @@ And in others panes you can run the containers:
    $ sudo docker run hello-world
    ```

    > **Note:** Teaching how to use tmux is out of the scope of this guide, you can find good tutorials on YouTube. If you don't wanna use a terminal multiplexer, you can run dockerd in the background instead, with `dockerd &> /dev/null &`.
    > **Note:** Teaching how to use tmux is out of the scope of this guide, you can find good tutorials on YouTube. If you don't wanna use a terminal multiplexer, you can run dockerd in the background instead, with `sudo dockerd &>/dev/null &`.
    ## 3.1. Caveats

    After months testing docker, the only thing I couldn't managed to get working 100% as intended is the internet. I'm not sure why, but the only way to get the containers to access the internet is to use the `--net=host` flag. Trying to isolate the container network almost work: the tun tap interface is created, but it doesn't seem to work.

    ## 3.2 GUI
    ## 3.2. GUI

    Yes, it's possible to run GUI programs inside a container! There's basically two ways of accomplishing it in a simple manner:

    @@ -596,7 +596,7 @@ LIBGL: ERROR: EGL Error detected: EGL_BAD_CONTEXT
    - [man/md2man-all.sh](https://github.com/termux/termux-root-packages/files/5793952/md2man-all.sh.patch.txt)
    - [cli/config/config.go](https://github.com/termux/termux-root-packages/files/5793948/config.go.patch.txt)

    ## 4.3 containerd patches
    ## 4.3. containerd patches

    - [runtime/v1/linux/bundle.go](https://github.com/termux/termux-root-packages/files/5793939/bundle.go.patch.txt)
    - [runtime/v2/shim/util_unix.go](https://github.com/termux/termux-root-packages/files/5793946/util_unix.go.patch.txt)
  27. @FreddieOliveira FreddieOliveira revised this gist Jan 22, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -118,7 +118,7 @@ Once you have a supported kernel, it's time to compile the docker suit. It's a s
    Firts, let's install the packages we're gonna use to build docker in Termux:

    ```
    $ pkg install go make
    $ pkg install golang make ndk-multilib
    ```

    Now we're ready to start compiling things. Create a work directory where the packages will be downloaded and built:
  28. @FreddieOliveira FreddieOliveira revised this gist Jan 22, 2021. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Docker packages are in the process of being added to [termux-root repo](https://

    ### ***Edit 2***

    [containerd](#233-containerd) has been added to termux-root repo already. If desired, just `pkg install containerd` instead of manually build it.
    [containerd](#235-containerd) has been added to termux-root repo already. If desired, just `pkg install containerd` instead of manually build it.

    ---

    @@ -238,7 +238,7 @@ $ cat << "EOF" > $PREFIX/etc/docker/daemon.json
    EOF
    ```

    **Warning:** dockerd will store all its files, like containers, images, volumes, etc inside the `/data/docker` folder, which means you'll lose everything if you format the phone (flash a ROM). This folder was chosen instead of storing things inside Termux installation folder, because dockerd fails when setting up the overlay storage driver there. It seems Android mounts the `/data/data` folder with some options that prevent overlayfs to work, or the filesystem doesn't support it.
    > **Warning:** dockerd will store all its files, like containers, images, volumes, etc inside the `/data/docker` folder, which means you'll lose everything if you format the phone (flash a ROM). This folder was chosen instead of storing things inside Termux installation folder, because dockerd fails when setting up the overlay storage driver there. It seems Android mounts the `/data/data` folder with some options that prevent overlayfs to work, or the filesystem doesn't support it.
    ### 2.3.3. tini

    @@ -312,7 +312,7 @@ imports = ["$PREFIX/etc/containerd/runtime_*.toml", "./debug.toml"]
    EOF
    ```

    **Note:** unfortunately containerd files also can't be stored inside Termux installation folder, failing with an error when creating the socket it uses.
    > **Note:** unfortunately containerd files also can't be stored inside Termux installation folder, failing with an error when creating the socket it uses.
    ### 2.3.6. runc

    @@ -342,7 +342,7 @@ And in others panes you can run the containers:
    $ sudo docker run hello-world
    ```

    **Note:** Teaching how to use tmux is out of the scope of this guide, you can find good tutorials on YouTube. If you don't wanna use a terminal multiplexer, you can run dockerd in the background instead, with `dockerd &> /dev/null &`.
    > **Note:** Teaching how to use tmux is out of the scope of this guide, you can find good tutorials on YouTube. If you don't wanna use a terminal multiplexer, you can run dockerd in the background instead, with `dockerd &> /dev/null &`.
    ## 3.1. Caveats

    @@ -374,17 +374,17 @@ Then install a VNC server in termux:
    $ pkg install tigervnc
    ```

    **Note:** These installations steps need to be executed only once.
    > **Note:** These installations steps need to be executed only once.
    Now, just run it:

    ```
    $ vncserver -noxstartup -localhost
    ```

    **Note:** It's advisable to pass the `-geometry HEIGHTxWEIGHT` flag substituting HEIGHT and WEIGHT by your phone's screen resolution or some multiple of it.
    > **Note:** It's advisable to pass the `-geometry HEIGHTxWEIGHT` flag substituting HEIGHT and WEIGHT by your phone's screen resolution or some multiple of it.
    **Note:** The very first time you run it, you'll be prompted to setup a password. Note that passwords are not visible when you are typing them and it's maximal length is 8 characters. If you don't wanna use a passwd, use the `-SecurityTypes none` flag.
    > **Note:** The very first time you run it, you'll be prompted to setup a password. Note that passwords are not visible when you are typing them and it's maximal length is 8 characters. If you don't wanna use a passwd, use the `-SecurityTypes none` flag.
    If everything is okay, you will see this message:

    @@ -410,7 +410,7 @@ $ sudo docker run -ti \
    ubuntu
    ```

    **Note:** If by any reason you forget to export the DISPLAY before starting the container, you can still export it from inside it.
    > **Note:** If by any reason you forget to export the DISPLAY before starting the container, you can still export it from inside it.
    You'll now be able to launch GUI programs from inside the container, e.g.:

    @@ -423,7 +423,7 @@ You'll now be able to launch GUI programs from inside the container, e.g.:

    To check the GUI, you'll need to install a VNC client app in your Android phone, like [VNC Viewer](https://play.google.com/store/apps/details?id=com.realvnc.viewer.android) (developed by RealVNC Limited). Unfortunately it's not open source, but it's a good and intuitive VNC client for Android.

    **Note:** There's also an open source alternative developed by @pelya called [XServer XSDL](https://github.com/pelya/xserver-xsdl), which will not be covered by this guide (for now).
    > **Note:** There's also an open source alternative developed by @pelya called [XServer XSDL](https://github.com/pelya/xserver-xsdl), which will not be covered by this guide (for now).
    After installing the VNC Viewer app, open it and setup a new connection using 127.0.0.1 (or localhost) as the IP, 5901 as the port (the port is calculated as 5900 + {display number}) and when/if prompted, type the password choosen when running vnctiger for the first time.

    @@ -534,7 +534,7 @@ $ sudo docker run -ti \
    arm32v7/ubuntu
    ```

    **Note:** if your system is 32 bit (run `uname -m` to check), you don't need to specify the `--platform=linux/arm` flag and can simply use `ubuntu` instead of `arm32v7/ubuntu`.
    > **Note:** if your system is 32 bit already (run `uname -m` to check), you don't need to specify the `--platform=linux/arm` flag and can simply use `ubuntu` instead of `arm32v7/ubuntu`.
    Now that we are inside the container, let's install the tools we're gonna use, as well as the steam .deb installer:

  29. @FreddieOliveira FreddieOliveira revised this gist Jan 22, 2021. 1 changed file with 36 additions and 4 deletions.
    40 changes: 36 additions & 4 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -22,8 +22,10 @@ Docker packages are in the process of being added to [termux-root repo](https://
    3. [Docker](#23-docker)
    1. [dockercli](#231-dockercli)
    2. [dockerd](#232-dockerd)
    3. [containerd](#233-containerd)
    4. [runc](#234-runc)
    3. [tini](#233-tini)
    4. [libnetwork](#234-libnetwork)
    5. [containerd](#235-containerd)
    6. [runc](#236-runc)
    3. [Running](#3-running)
    1. [Caveats](#31-caveats)
    2. [GUI](#32-gui)
    @@ -238,7 +240,37 @@ EOF

    **Warning:** dockerd will store all its files, like containers, images, volumes, etc inside the `/data/docker` folder, which means you'll lose everything if you format the phone (flash a ROM). This folder was chosen instead of storing things inside Termux installation folder, because dockerd fails when setting up the overlay storage driver there. It seems Android mounts the `/data/data` folder with some options that prevent overlayfs to work, or the filesystem doesn't support it.

    ### 2.3.3. containerd
    ### 2.3.3. tini

    tini is an optional dependency of dockerd in case you want the `init` process to be the first process of the container being ran (for this use the `--init` flag when creating a container). Having `init` as the parent of all other proccess ensures that a proper clean up inside the container is made when it exits.

    ```
    $ wget https://github.com/krallin/tini/archive/v0.19.0.tar.gz
    $ tar xf v0.19.0.tar.gz
    $ cd tini-0.19.0
    $ mkdir build
    $ cd buid
    $ cmake -DCMAKE_BUILD_TYPE=Release ..
    $ make -j8
    $ install -Dm 0700 tini-static $PREFIX/bin/tini
    $ ln -s $PREFIX/bin/tini $PREFIX/bin/docker-init
    ```

    ### 2.3.4. libnetwork

    Another dockerd dependency needed when using the `-p` flag while creating a container:

    ```
    $ wget https://github.com/moby/libnetwork/archive/448016ef11309bd67541dcf4d72f1f5b7de94862.tar.gz
    $ tar xf 448016ef11309bd67541dcf4d72f1f5b7de94862.tar.gz
    $ export GOPATH="$(pwd)"
    $ cd libnetwork-448016ef11309bd67541dcf4d72f1f5b7de94862
    $ go build -o docker-proxy github.com/docker/libnetwork/cmd/proxy
    $ strip docker-proxy
    $ install -Dm 0700 docker-proxy $PREFIX/bin/docker-proxy
    ```

    ### 2.3.5. containerd

    See [Edit 2](#edit-2).

    @@ -282,7 +314,7 @@ EOF

    **Note:** unfortunately containerd files also can't be stored inside Termux installation folder, failing with an error when creating the socket it uses.

    ### 2.3.4. runc
    ### 2.3.6. runc

    runc is a dependency of containerd. Conveniently for us, it's already provided by Termux's repository. Install it by simply:

  30. @FreddieOliveira FreddieOliveira revised this gist Jan 21, 2021. No changes.