Skip to content

itisFarzin/DockerOnTermux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Docker On Termux

This note is more or less a personal note

You have to follow FreddieOliveira's guide to set up Docker on Termux, This includes:

After that, you will hopefully be able to run Docker on Termux, but (for me) there was a problem: network driver. The bridge network driver crashed my phone, and I struggled to figure out what was happening. After switching to the host network driver, Docker worked successfully, and I was able to run some containers.

So I wrote a simple wrapper for Docker to use host network driver for containers and run Docker commands with sudo:

export DOCKER_HOST="unix:///data/docker/run/docker.sock"  # Default path is unix://$PREFIX/var/run/docker.sock

function docker {
    if [ "$1" = "run" ]; then
        shift
        command sudo docker run --network=host "$@"
    elif [ "$1" = "create" ]; then
        shift
        command sudo docker create --network=host "$@"
    elif [ "$1" = "build" ]; then
        shift
        command sudo docker build --network=host "$@"
    else
        command sudo -E docker "$@"
    fi
}

But something isn't right. For example, after Docker has been running if I restart the phone, running Docker again still causes Android to crash, it seems like it wants to start/create the bridge interface. After some investigation I found out if I remove the $PREFIX/lib/docker/network folder before running Docker, it fixes the issue.

So I added this line to the $PREFIX/var/service/dockerd/run file:

rm -rf /data/data/com.termux/files/usr/lib/docker/network

I hope you find this note helpful.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published