Open sandyboxy opened 10 months ago
I also tried to mount volumes in this way but without success:
volumes:
- ./android:/root/.android/
- ./android-emulator:/root/android_emulator
Having the same issue here. Tried it with privileged: true and the same volumes as @sandyboxy.
I solved by mounting the following volumes:
- data:/home/androidusr
- root:/root
Hope this helps!
Thanks! @sandyboxy Here's a complete .yml file to anyone who wants to persist the data
version: '3.3'
services: docker-android: ports:
volumes: data: root:
I tried restarting with the same config file, but observed in logs/device.stdout.log
. Not sure if anyone here got the same issue
File "/home/androidusr/docker-android/cli/src/app.py", line 77, in start_device
selected_device.start()
File "/home/androidusr/docker-android/cli/src/device/emulator.py", line 160, in start
self.change_permission()
File "/home/androidusr/docker-android/cli/src/device/emulator.py", line 142, in change_permission
subprocess.check_call(c, shell=True)
File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'sudo chown 1300:1301 /dev/kvm' returned non-zero exit status 1.```
have same problem with @llai-utexas. Did you find a way?
@ErcinDedeoglu I realize restarting the same docker container was the wrong way to keep the state. I follwed this suggestion here https://github.com/budtmo/docker-android/issues/129#issuecomment-493316051
I've found that if before stopping and rm the container I turn off the emulator phone on novnc, this issue goes away.
So what I did was using the volume mount confirguration listed above, but with a fresh docker container, while making sure the emulator was turned off in the last container, and the state was persisted
@llai-utexas thanks a lot for your quick reply. It sounds like a lot of procedures to run for a docker container. I think this would be a maintenance failure for me. :) I found this: https://github.com/budtmo/docker-android/issues/364#issuecomment-1602755915 It says "you need to pay". If the owner (@budtmo) of repository confirm, then I'll check paid option if it is well maintained.
@ErcinDedeoglu I saw that comment as well. I had the pro version as well. While I would not run into the sudo issue, the emulator would not boot up properly (I think sudo privilege for pro version literally means just that, it doesn't mean restart with state persisted
). The only way that worked for me to persist the emulator state, was creating fresh container, for both pro and free versions
I have managed to get the restart to work and persist the information. To do this I have created a Dockerfile that overwrites the original and restores the root user. I leave you the Dockerfile and docker-compose.yaml used in case it helps anyone.
Dockerfile
FROM budtmo/docker-android:emulator_11.0
USER root
RUN echo 'root:x:0:0:root:/root:/bin/bash' >> /etc/passwd
USER androidusr
docker-compose.yaml
version: '3.7'
services:
android-container:
image: budtmo/docker-android:emulator_11.0
build:
context: .
container_name: android-container
privileged: true
environment:
- EMULATOR_DEVICE=Samsung Galaxy S10
- WEB_VNC=true
volumes:
- data:/home/androidusr
- root:/root
ports:
- "6080:6080"
devices:
- "/dev/kvm:/dev/kvm"
restart: always
volumes:
data:
root:
After a few days working with this image, I have continued to face some problems, they are now being fixed.
Dockerfile
FROM budtmo/docker-android:emulator_11.0
USER root
RUN echo 'root:x:0:0:root:/root:/bin/bash' >> /etc/passwd
USER androidusr
COPY run.sh /run.sh
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/run.sh"]
run.sh
#!/bin/bash
rm -rf /home/androidusr/emulator/*.lock
/home/androidusr/docker-android/mixins/scripts/run.sh
docker-compose.yaml
version: '3.7'
services:
android-container:
build:
context: .
container_name: android-container
privileged: true
environment:
- EMULATOR_DEVICE=Samsung Galaxy S10
- WEB_VNC=true
- WEB_LOG=true
- WEB_LOG_PORT=9000
- VNC_PASSWORD=yRBLPq4h5bVAzDT83f6jQX
- ENV_LOG_PATH=/var/log/
volumes:
- data:/home/androidusr
- root:/root
ports:
- "6080:6080"
- "9005:9000"
devices:
- "/dev/kvm:/dev/kvm"
restart: always
volumes:
data:
root:
same problem, after using @bernatvadell 's method, appium still fail
the log of it is helpless:
INFO App - env APPIUM cannot be found, Appium is not started!
OMG, this works for persisting data! Thank you so much! Dont forget to chmod +x on the run.sh before copy.
OMG, this works for persisting data! Thank you so much! Dont forget to chmod +x on the run.sh before copy.
Thank you @jamtheim for the headsup. The file will end being:
Dockerfile
FROM budtmo/docker-android:emulator_11.0
USER root
RUN echo 'root:x:0:0:root:/root:/bin/bash' >> /etc/passwd
USER androidusr
COPY run.sh /run.sh
RUN chmod +x /run.sh
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/run.sh"]
the log of it is helpless:
INFO App - env APPIUM cannot be found, Appium is not started!
Try using this docker-compose.yaml
:
version: '3.8'
services:
android-container:
build:
context: .
container_name: android-container
# privileged: true
environment:
- EMULATOR_DEVICE=Samsung Galaxy S6
- WEB_VNC=true
- WEB_LOG=true
- WEB_LOG_PORT=9000
# - VNC_PASSWORD=yRBLPq4h5bVAzDT83f6jQX
- ENV_LOG_PATH=/var/log/
- APPIUM=true
volumes:
- data:/home/androidusr
- root:/root
ports:
- "6080:6080"
- "9005:9000"
- "4723:4723"
devices:
- "/dev/kvm:/dev/kvm"
restart: always
volumes:
data:
root:
Notice I am adding:
APPIUM=true
"4723:4723"
Operating System
Ubuntu 22.04
Docker Image
budtmo/docker-android:emulator_13.0
Expected behaviour
Hello, this is my docker-compose based on @SudhanvaManjunath post
Actual behaviour
When I stop docker and restart it I have a new phone with default settings and without my previous settings and data.