title: Move existing Android Emulator (AVD) to Docker container
body: <p>I need to include existing android emulator with the changes included in it (qcow2 files) in the docker image.</p>
  
  <p>Sequencing:</p>
  
  <p>1) Create an emulator through the Android Studio</p>
  
  <p>2) Run it with the <code>-writable-system</code> option</p>
  
  <pre><code>emulator -avd xposed -writable-system
  </code></pre>
  
  <p>3) Make the necessary changes (Xposed installation, some xposed modules, data recording on the SD card and so on). All of these changes writing to qcow2 files (system.img.qcow2, sdcard.img.qcow2, etc.)</p>
  
  <p>4) Stop the emulator</p>
  
  <p>5) Archive it</p>
  
  <pre><code>cd /home/user/.android/avd &amp;&amp; tar -cvzf xposed.tar.gz .
  </code></pre>
  
  <p>6) In the docker file:</p>
  
  <pre><code>ADD xposed.tar.gz /root/.android/avd
  </code></pre>
  
  <p>7) In <code>xposed.ini</code> change absolute path to the emulator instance</p>
  
  <pre><code>path=/root/.android/avd/xposed.avd
  </code></pre>
  
  <p>When try to run the emulator inside the docker - the qcow2 files with changes  are recreated instead of used existing. :(</p>
  
  <p>I get the same android-sdk tools and emulator versions, the same JDK and so on.</p>
  
  <p>Also trying to change paths in harware-qemu.ini to the new one (<code>/root/.android/avd/xposed/....</code>) but no luck.</p>
  
  <p>Some information about system and docker:</p>
  
  <p>1) Android version 23 (6.0) x86 google_apis image</p>
  
  <p>2) Run docker command:</p>
  
  <pre><code>sudo docker run -d -p 5900:5900 -p 5555:5555 --privileged -v /dev/kvm:/dev/kvm --name xposed xposed
  </code></pre>
  
  <p>3) Run android emulator command:</p>
  
  <pre><code>usr/local/android-sdk/emulator/emulator -avd xposed -noaudio -no-window -gpu off -verbose -qemu -usbdevice tablet -vnc :0
  </code></pre>
  
  <p>I really don`t know what to do. It is real, one time a have a luck, I get it and it was working great, but I lost this state and now nothing happens :(</p>
  
  <p>By the way, in normal behavior I will get an error, like:</p>
  
  <pre><code>avd\system.img.qcow2,read-only: Could not open backing file: Could not open .....
  </code></pre>
  
  <p>But now no errors, it just override my files :(</p>