Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悰 Bug ]: Device data reset when docker restart #395

Open
sandyboxy opened this issue Nov 9, 2023 · 11 comments
Open

[馃悰 Bug ]: Device data reset when docker restart #395

sandyboxy opened this issue Nov 9, 2023 · 11 comments
Labels

Comments

@sandyboxy
Copy link

sandyboxy commented Nov 9, 2023

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

version: '3'
services:
  android-container:
    image: budtmo/docker-android:emulator_13.0
    #deploy:
    # resources:
    #  limits:
    #   cpus: '8'
    #   memory: 10000M
    #  reservations:
    #   cpus: '8'
    #   memory: 10000M
    privileged: true
    ports:
      - 4723:4723
      - 5555:5555
    #  - 9000
      - 6080:6080
    volumes:
      - ./video-samsung_13.0:/tmp/video
    environment:
      - EMULATOR_DEVICE="Samsung Galaxy S10"
     # - APPIUM=true
      - WEB_VNC=true
     # - WEB_LOG=true
     # - WEB_LOG_PORT=9000
    devices:
      - "/dev/kvm"

Actual behaviour

When I stop docker and restart it I have a new phone with default settings and without my previous settings and data.

@sandyboxy sandyboxy added the bug label Nov 9, 2023
@sandyboxy
Copy link
Author

I also tried to mount volumes in this way but without success:

    volumes:
      - ./android:/root/.android/
      - ./android-emulator:/root/android_emulator

@Lumino2
Copy link

Lumino2 commented Nov 13, 2023

Having the same issue here. Tried it with privileged: true and the same volumes as @sandyboxy.

@sandyboxy
Copy link
Author

I solved by mounting the following volumes:

- data:/home/androidusr
- root:/root

Hope this helps!

@Lumino2
Copy link

Lumino2 commented Nov 17, 2023

Thanks! @sandyboxy
Here's a complete .yml file to anyone who wants to persist the data

version: '3.3'

services:
docker-android:
ports:
- '6080:6080'
- '5555:5555'
- '5554:5554'
privileged: true
environment:
- 'EMULATOR_DEVICE=Samsung Galaxy S10'
- WEB_VNC=true
volumes:
- data:/home/androidusr
- root:/root
devices:
- "/dev/kvm:/dev/kvm"
container_name: android-container
image: 'budtmo/docker-android:emulator_11.0'

volumes:
data:
root:

@llai-utexas
Copy link

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.```

@ErcinDedeoglu
Copy link

have same problem with @llai-utexas. Did you find a way?

@llai-utexas
Copy link

@ErcinDedeoglu I realize restarting the same docker container was the wrong way to keep the state. I follwed this suggestion here #129 (comment)

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

@ErcinDedeoglu
Copy link

@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:
#364 (comment)
It says "you need to pay".
If the owner (@budtmo) of repository confirm, then I'll check paid option if it is well maintained.

@llai-utexas
Copy link

llai-utexas commented Jan 28, 2024

@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

@bernatvadell
Copy link

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:

@bernatvadell
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants