Skip to content

Commit

Permalink
attemps to shove anbox into docker
Browse files Browse the repository at this point in the history
  • Loading branch information
meyerson committed Dec 7, 2018
1 parent c8a760c commit 17131a3
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 0 deletions.
131 changes: 131 additions & 0 deletions 2018-09-16-anbox-archlinux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# install

# use

#automation

# sources
https://github.com/anbox/anbox/issues/305



To run in the arch (I used yaourt) I first installed the system kernel headers for the DKMS.

"yaourt -s linux-headers" (I found the version compatible with my my kernel - 4.10.12-1-MANJARO)
Then I compiled the anbox with the following packages:

"aur/anbox-git"
"aur/anbox-image"
"aur/anbox-modules-dkms-git"
I started systemd networks services (for internet to work in apps)

"sudo systemctl start systemd-resolved.service"
"sudo systemctl start systemd-networkd.service"
And started the container-manager service

"sudo systemctl start anbox-container-manager.service"
I added the host driver in /usr/lib/systemd/user/anbox-session-manager.service by changing the line:

From "ExecStart=/usr/bin/anbox session-manager"
To "ExecStart=/usr/bin/anbox session-manager --gles-driver=host"
I started the user service:

"systemctl --user start anbox-session-manager.service"
Then it worked!


# Create a portable android via docker

load modules before compiling?
## host os
ashmem and binder

[cryosphere@sd_arch anbox]$ lsmod | grep bind
binder_linux 118784 60
[cryosphere@sd_arch anbox]$ lsmod | grep ashmem
ashmem_linux 16384 9


## build it

git clone here or docker pull this

## download a pre-build android image

wget https://build.anbox.io/android-images/2018/06/11/android_amd64.img


### run it

docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --privileged dmeyerson:anbox /bin/bash


docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -v /mnt/store/android_images:/var/lib/anbox/ --privileged dmeyerson:anbox /bin/bash

docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -v /mnt/store/android_images:/var/lib/anbox/ --privileged -v /tmp/.X11-unix:/tmp/.X11-unix dmeyerson:anbox /bin/bash

## sessopm ,
## GUI apps on docker

https://medium.com/@SaravSun/running-gui-applications-inside-docker-containers-83d65c0db110




##
# troubleshooting
### debug
docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --privileged dmeyerson:anbox /bin/bash run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --privileged -v /tmp/.X11-unix:/tmp/.X11-unix local:anbox /bin/bash




### access to kernel modules
root@22650413b559:/anbox/build# anbox session-manager
2018-10-21 17:23:19] [session_manager.cpp:130@operator()] Failed to start as either binder or ashmem kernel drivers are not loaded

on the container - verify ashmem and binder
root@90b5b5028fd2:/anbox/build# anbox system-info | grep bind
binder: false
root@90b5b5028fd2:/anbox/build# anbox system-info | grep ash
ashmem: false

make sure you are running with --privileged flag and binder + ashmem are loaded in host OS

## runtime env issues
[cryosphere@sd_arch anbox]$ docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --privileged -v /tmp/.X11-unix:/tmp/.X11-unix local:anbox /bin/bash
root@sd_arch:/anbox/build# anbox session-manager
[ 2018-10-21 18:07:30] [daemon.cpp:61@Run] No runtime directory specified

reading https://github.com/anbox/anbox/issues/597
make sure the flag is present -e XDG_RUNTIME_DIR={} arg
attemped ad-hoc from w/in the container
root@sd_arch:/anbox/build# export XDG_RUNTIME_DIR=/run/user/1000 # same as hose os?


## socket error
[ 2018-10-21 18:13:17] [daemon.cpp:61@Run] Failed to connect to socket /run/anbox-container.socket: No such file or directory
reading https://github.com/anbox/anbox/issues/123
indicates that we need to start the container manager first?

## current state
docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -v /mnt/store/android_images:/var/lib/anbox/ --privileged -e XDG_RUNTIME_DIR=/run/user/1000 -e ANBOX_LOG_LEVEL='trace' local:anbox /bin/bash

anbox container-manager --daemon --privileged --data-path=/var/lib/anbox &

root@sd_arch:/anbox/build# anbox session-managerls
[ 2018-10-21 22:01:42] [Renderer.cpp:168@initialize] Using a surfaceless EGL context
[ 2018-10-21 22:01:42] [Renderer.cpp:251@initialize] Successfully initialized EGL
[ 2018-10-21 22:01:42] [service.cpp:41@Service] Successfully acquired DBus service name
[ 2018-10-21 22:01:42] [client.cpp:49@start] Failed to start container: Failed to start

## next
https://github.com/mviereck/x11docker


# current state
docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -v /mnt/store/android_images:/var/lib/anbox/ --privileged -e XDG_RUNTIME_DIR=/run/user/1000 -e ANBOX_LOG_LEVEL='trace' local:base_anbox /bin/bash

# two layer build process
docker build -t local:base_anbox ./
docker build -t local:config_anbox -f ./Dockerfile_config ./
76 changes: 76 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/sh
FROM ubuntu:18.04

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
cmake-data \
cmake-extras \
debhelper \
dbus \
dbus-x11 \
git \
google-mock \
libboost-dev \
libboost-filesystem-dev \
libboost-log-dev \
libboost-iostreams-dev \
libboost-program-options-dev \
libboost-system-dev \
libboost-test-dev \
libboost-thread-dev \
libcap-dev \
libegl1-mesa-dev \
libgles2-mesa-dev \
libglib2.0-dev \
libglm-dev \
libgtest-dev \
liblxc1 \
libproperties-cpp-dev \
libprotobuf-dev \
libsdl2-dev \
libsdl2-image-dev \
libsystemd-dev \
lxc-dev \
pkg-config \
protobuf-compiler \
iproute2 \
iptables \
kmod \
x11-apps
# apt-get clean

WORKDIR /anbox

# cleanup() {
# # In cases where anbox comes directly from a checked out Android
# # build environment we miss some symlinks which are present on
# # the host and don't have a valid git repository in that case.
# clear


#if [ -d .git ] ; then
# admp
#ls git clean -fdx .
# git reset --hard
# ad fi
# }
# cleanup
#COPY CMakeLists.txt CMakeLists.txt
#COPY src src
COPY . /anbox
RUN mkdir build || rm -rf build/*
RUN ls
WORKDIR /anbox/build
RUN cmake ..
RUN VERBOSE=1 make -j10
RUN VERBOSE=1 make test
RUN make install
ENV ANBOX_LOG_LEVEL='trace'
#RUN export $(dbus-launch)
# VERBOSE=1 make test
# todo - use wget to get a version controlled android image.
#COPY android.img /var/lib/anbox/android.img
#ENTRYPOINT ["anbox container-manager --daemon --privileged --data-path=/var/lib/anbox"]

#docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -v /mnt/store/android_images:/var/lib/anbox/ --privileged -v /tmp/.X11-unix:/tmp/.X11-unix local:anbox /bin/bash
14 changes: 14 additions & 0 deletions Dockerfile_alt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
FROM ubuntu:18.04

RUN apt-get update && apt-get install -y \
build-essential \
software-properties-common \
kmod \
snapd \
sudo
RUN add-apt-repository -y ppa:morphis/anbox-support
RUN apt update
RUN apt install snapd
#apt install anbox-modules-dkms
#docker run -it --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -v /mnt/store/android_images:/var/lib/anbox/ --privileged -v /tmp/.X11-unix:/tmp/.X11-unix local:fast_anbox /bin/bash
16 changes: 16 additions & 0 deletions Dockerfile_alt_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$ sudo add-apt-repository ppa:morphis/anbox-support
$ sudo apt update
$ sudo apt install anbox-modules-dkms

```
$ sudo modprobe ashmem_linux
$ sudo modprobe binder_linux
```

```
$ snap install --devmode --beta anbox


```
$ snap info anbox
```
24 changes: 24 additions & 0 deletions Dockerfile_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
FROM local:anbox

# VERBOSE=1 make test
# todo - use wget to get a version controlled android image.
#COPY android.img /var/lib/anbox/android.img
#ENTRYPOINT ["anbox container-manager --daemon --privileged --data-path=/var/lib/anbox"]
#export $(dbus-launch)
service dbus start

#run as service
anbox container-manager --daemon --privileged --data-path=/var/lib/anbox

export $(dbus-launch)

./anbox-bridge.sh start

export XDG_RUNTIME_DIR=/run/user/1000
anbox session-manager

# #ip link add dev "${BRIDGE}" type bridge
# # logs
# 12 cat /var/lib/anbox/logs/container.log
# 13 cat /var/lib/anbox/logs/console.log
1 change: 1 addition & 0 deletions scripts/anbox-bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ start() {
set -e

# set up the anbox network
echo ${BRIDGE}
[ ! -d "/sys/class/net/${BRIDGE}" ] && ip link add dev "${BRIDGE}" type bridge

# if we are run from systemd on a system with selinux enabled,
Expand Down

0 comments on commit 17131a3

Please sign in to comment.