In this tutorial, we will guide you through the process of installing Docker on your Android phone, specifically using a OnePlus 6T with postmarketOS. However, this guide can be adapted only for phones on the postmarketOS device list. Please note that this process will erase all data on your phone, so it’s important to use a device you don’t need. Let’s get started!

What do you need for this tutorial?

  • An Android phone (OnePlus 6T is recommended)
  • Fastboot installed on your PC (see step 2)
  • PostmarketOS boot and img files (see step 3)

Step 1: Enable Developer Mode and USB Debugging

Enable Developer Mode and USB Debugging Start by activating Developer Mode on your Android phone.

Go to Settings, tap on “Build number” repeatedly until you see a message indicating that Developer Mode has been enabled. Then, go to Developer options and activate OEM unlocking and USB debugging.

developer-options-980x522

Step 2: Install Fastboot on your PC

Install Fastboot on your PC To proceed with the installation, you’ll need to have Fastboot installed on your PC. Visit the official Android SDK Platform Tools page and download the package. Extract the files and add the platform-tools folder to your system’s environment variables (instructions vary depending on your operating system).

adb-980x510

Step 3: Download PostmarketOS Files

Download the PostmarketOS boot and img files for your specific phone model. Visit the postmarketOS website, locate the appropriate files (I am using phosh 22.12), and download them. Extract the files and place them in a single folder for easy access.

postmarketos-download-980x393

Step 4: Enter Fastboot Mode

Restart your Android phone and boot it into Fastboot mode. This can typically be done by pressing the volume up, volume down, and power buttons simultaneously on Oneplus 6t. Once your phone is in Fastboot mode, connect it to your PC using a USB cable.

buttons-868x1024
fastboot-mode-oneplus-6t-665x102

Step 5: Flash PostmarketOS

Flash PostmarketOS on Your Phone by opening a command prompt or terminal window on your PC and navigate to the folder where you saved the PostmarketOS files. Execute the following commands one by one:

  fastboot erase userdata
  
  fastboot erase dtbo
  
  fastboot flash boot boot_file_name.img
  
  fastboot flash userdata img_file_name.img
  

Replace “boot_file_name” and “img_file_name” with the actual file names you saved earlier. Once the flashing process is complete, restart your phone.

files-with-cmd-980x536
PostmarketOS ist installed now on your phone!

Step 6: Initial Setup and SSH Activation

When your phone restarts, you may be prompted for a PIN.

Use the default PIN, which is usually “147147.” Connect your phone to a Wi-Fi network. Open the Console app on your phone and activate SSH to control the phone from your PC. Run the following commands in the Console app on your phone:

  sudo service sshd start
  
  sudo rc-update add sshd
  
Console-postmarketos-768x1024

Step 7: Connect to Your Phone via SSH on your PC

On your PC, open a command prompt or terminal window and connect to your phone via SSH using the following command:

  ssh user@IP_Address_of_the_phone
  

The default username for SSH is “user,” but you can verify this by running the “whoami” command on the Console app of your phone. The IP_Address_of_the_phone can be found by typing “ifconfig” in the Console app and looking for the IP of wlan0.

Step 8: Install Docker on your Android Phone

Now that you’re connected to your phone via SSH, you can easily install Docker by running the following commands:

  sudo apk add docker
  
  sudo service docker start
  
  sudo rc-update add docker default
  

To verify that Docker is installed correctly, run:

  sudo docker ps
  

DONE! Run Docker Containers

With Docker successfully installed on your Android phone, you can now run Docker containers and use your phone as a home server. Let’s try running the Portainer container as an example:

Run the following command to start the Portainer container which will download the Portainer image and start the container.:

sudo docker run -d -p 8000:8000 -p 9443:9443 –name portainer –restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

portainer-installed-1

Portainer provides a web-based interface for managing Docker containers and it is easy to use.

Access Portainer Interface

Open your web browser on your PC and type in the IP_Address_of_the_phone, followed by “:9443”. This will take you to the Portainer interface running on your Android phone. You can now manage and monitor your Docker containers through this interface.

Congratulations! You have successfully installed Docker on your Android phone and set up a Docker container. You can now explore various Docker images and run them on your phone to expand its capabilities as a home server.

I am currently using several containers on my home server, and if you’re interested, in the picture below you will see the memory usage.

This method serves as an excellent alternative to Raspberry Pi. While I haven’t personally tried a Raspberry Pi before, I believe this phone is more capable, with the added advantage of an integrated screen and battery, which are not available with a Raspberry Pi.

portainer-980x577