mirror of
https://github.com/HQarroum/docker-android.git
synced 2026-07-30 03:12:18 +00:00
fix: wipe/restart lost date (#3)
This commit is contained in:
+6
-4
@@ -4,9 +4,9 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
#WORKDIR /
|
||||
#=============================
|
||||
# Install Dependenices
|
||||
# Install Dependenices
|
||||
#=============================
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
RUN apt update && apt install -y curl \
|
||||
sudo wget unzip bzip2 libdrm-dev \
|
||||
@@ -41,7 +41,8 @@ ENV ANDROID_SDK_ROOT=/opt/android \
|
||||
ABI=${IMG_TYPE}/${ARCHITECTURE} \
|
||||
GPU_ACCELERATED=$GPU_ACCELERATED \
|
||||
QTWEBENGINE_DISABLE_SANDBOX=1 \
|
||||
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10
|
||||
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10 \
|
||||
ANDROID_AVD_HOME=/data
|
||||
|
||||
# Exporting environment variables to keep in the path
|
||||
# Android SDK binaries and shared libraries.
|
||||
@@ -59,7 +60,8 @@ EXPOSE 5554 5555
|
||||
|
||||
# Initializing the required directories.
|
||||
RUN mkdir /root/.android/ && \
|
||||
touch /root/.android/repositories.cfg
|
||||
touch /root/.android/repositories.cfg && \
|
||||
mkdir /data
|
||||
|
||||
# Exporting ADB keys.
|
||||
#COPY keys/* /root/.android/
|
||||
|
||||
+4
-2
@@ -44,7 +44,8 @@ ENV ANDROID_SDK_ROOT=/opt/android \
|
||||
ABI=${IMG_TYPE}/${ARCHITECTURE} \
|
||||
GPU_ACCELERATED=$GPU_ACCELERATED \
|
||||
QTWEBENGINE_DISABLE_SANDBOX=1 \
|
||||
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10
|
||||
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10 \
|
||||
ANDROID_AVD_HOME=/data
|
||||
|
||||
# Exporting environment variables for keeping in the path
|
||||
# Android SDK binaries and shared libraries.
|
||||
@@ -62,7 +63,8 @@ EXPOSE 5554 5555
|
||||
|
||||
# Initializing the required directories.
|
||||
RUN mkdir /root/.android/ && \
|
||||
touch /root/.android/repositories.cfg
|
||||
touch /root/.android/repositories.cfg && \
|
||||
mkdir /data
|
||||
|
||||
# Exporting ADB keys.
|
||||
#COPY keys/* /root/.android/
|
||||
|
||||
@@ -76,7 +76,6 @@ You can generate one by running `adb keygen adbkey`, that generates 2 files - ad
|
||||
|
||||
override them inside ./keys directory.
|
||||
|
||||
|
||||
### Running the container
|
||||
|
||||
Once the image is built, you can mount your KVM driver on the container and expose its ADB port.
|
||||
@@ -87,6 +86,14 @@ Once the image is built, you can mount your KVM driver on the container and expo
|
||||
docker run -it --rm --device /dev/kvm -p 5555:5555 android-emulator
|
||||
```
|
||||
|
||||
### Save data/storage after restart (wipe)
|
||||
|
||||
All avd save in docker dir `/data`, name for avd is `android`
|
||||
|
||||
```bash
|
||||
docker run -it --rm --device /dev/kvm -p 5555:5555 -v ~/android_avd:/data android-emulator
|
||||
```
|
||||
|
||||
### Connect ADB to the container
|
||||
|
||||
The ADB server in the container will be spawned automatically and listen on all interfaces in the container. After a few seconds, once the kernel has booted, you will be able to connect ADB to the container.
|
||||
|
||||
@@ -23,6 +23,7 @@ services:
|
||||
volumes:
|
||||
- ./keys/adbkey:/root/.android/adbkey:ro
|
||||
- ./keys/adbkey.pub:/root/.android/adbkey.pub:ro
|
||||
- ./android_avd:/data
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
|
||||
@@ -25,14 +25,19 @@ socat tcp-listen:"$ADB_PORT",bind="$LOCAL_IP",fork tcp:127.0.0.1:"$ADB_PORT" &
|
||||
export USER=root
|
||||
|
||||
# Creating the Android Virtual Emulator.
|
||||
echo "Creating the Android Virtual Emulator ..."
|
||||
echo "Using package '$PACKAGE_PATH', ABI '$ABI' and device '$DEVICE_ID' for creating the emulator"
|
||||
echo no | avdmanager create avd \
|
||||
--force \
|
||||
--name android \
|
||||
--abi "$ABI" \
|
||||
--package "$PACKAGE_PATH" \
|
||||
--device "$DEVICE_ID"
|
||||
TEST_AVD="$(emulator -list-avds | grep android)"
|
||||
if [ -z "$TEST_AVD" ]; then
|
||||
echo "Use the exists Android Virtual Emulator ..."
|
||||
else
|
||||
echo "Creating the Android Virtual Emulator ..."
|
||||
echo "Using package '$PACKAGE_PATH', ABI '$ABI' and device '$DEVICE_ID' for creating the emulator"
|
||||
echo no | avdmanager create avd \
|
||||
--force \
|
||||
--name android \
|
||||
--abi "$ABI" \
|
||||
--package "$PACKAGE_PATH" \
|
||||
--device "$DEVICE_ID"
|
||||
fi
|
||||
|
||||
if [ "$OPT_SKIP_AUTH" == "true" ]; then
|
||||
AUTH_FLAG="-skip-adb-auth"
|
||||
|
||||
Reference in New Issue
Block a user