Move existing Android Emulator (AVD) to Docker container Move existing Android Emulator (AVD) to Docker container docker docker

Move existing Android Emulator (AVD) to Docker container


I had the same problem when copying the emulator from the host to a docker container: the emulator inside docker would always start (in the best case) clean as after a factory reset, ignoring all my changes. This is how I solved the problem:

  • I started the emulator inside the docker container and I installed everything I needed (Xposed, custom apks etc.) while the emulator was running in docker.
  • After the emulator was setup the way I wanted, I turned if off and copied the /root/.android/avd/<emulator name> directory from the docker container to the host computer (by using docker cp command). This way I obtained a backup copy of the emulator with all the custom settings that can be used with docker.
  • I built a new docker image containing all the sdk stuff and tools needed to run the emulator and I added to the image the /root/.android/avd/<emulator name> directory previously saved. Now when I start a docker container from the new image I have a working emulator with all the settings I need.

Bonus tip: if you want to use the snapshot feature of the emulator, you have to commit the changes in the container to a new image (see docker commit command) and then use that new image, simply copying the avd directory will not work in this case and your snapshot will always be ignored.