anka run
requires Remote Login to be enabled for the user.
If the VM is in a suspended or stopped state,
anka run
will start it.
There are currently two methods of accessing Anka VMs:
anka run
> sudo anka run --help
Usage: anka run [OPTIONS] VM_NAME COMMAND [ARGS]...
Run commands inside VM environment
Options:
-w, --workdir PATH Working directory inside the VM
-v, --volumes-from, --volume PATH
Mount host directory (current directory by default) into VM . '--volumes-from' is
deprecated form
-n, --no-volumes-from, --no-volume
Use this flag to prevent implicit mounting of current folder (see --volume option).
'--no-volumes-from' is deprecated form
-E, -e, --env Inherit environment variables. '-e' is deprecated form
-f, --env-file PATH Provide environment variables from file
-N, --wait-network Wait till guest network interface up
-T, --wait-time Wait for guest time sync
--help Show this message and exit.
Similar to docker exec
, anka run
allows execution of commands inside of a VM.
When running anka run
with no options/flags, it will mount the current folder from the host into the VM and execute commands in this mount point. This can be disabled using the -n
option.
Returns 125 on timeout
sudo anka run {template} sudo whoami
HELPERS="set -exo pipefail;"
ANKA_RUN="sudo anka run -N -n"
$ANKA_RUN {template} bash -c "$HELPERS cd /tmp && rm -f /tmp/OpenJDK* && \
curl -L -O https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_x64_mac_hotspot_8u242b08.pkg && \
[ \$(du -s /tmp/OpenJDK8U-jdk_x64_mac_hotspot_8u242b08.pkg | awk '{print \$1}') -gt 190000 ] && \
sudo installer -pkg /tmp/OpenJDK8U-jdk_x64_mac_hotspot_8u242b08.pkg -target / && \
[[ ! -z \$(java -version 2>&1 | grep 1.8.0_242) ]] && \
rm -f /tmp/OpenJDK8U-jdk_x64_mac_hotspot_8u242b08.pkg"
It's also possible to specify the directory to mount inside of the VM using this syntax -v /host/folder:/mnt/path
:
sudo anka run -v $PWD:/tmp/mountpoint_1 {template} pwd
Currently, only a single directory can be specified. If you need more than one folder shared between host and the VM, use the
anka mount
command:
sudo anka mount {template} ~/Library/MobileDevice/Provisioning\ Profiles/ /Users/anka/Library/MobileDevice/Provisioning\ Profiles/
sudo anka run {template} xcodebuild -exportOptionsPlist exportInfo.plist archive
You can pass them inside of a file like anka run -f environment.txt
, where environment.txt is a text file in the form VARIABLE=VALUE
, one variable per line.
To inherit the host's environment, use anka run -E
command. However, existing VM variables will not be overridden by host's variables.
The anka run
command doesn't source .profile or .bash_profile. You have to source the file before executing other commands:
sudo anka run ios-temp bash -c 'source ~/.bash_profile; ./iPhone/make_build -b dev -c 1 -d ./build -e Mobile -z'`
anka run sierrav40c1 xcodebuild -sdk iphonesimulator -scheme Kickstarter-iOS build
- Will mount the default directory from the host into the sierrav40c1 Vm and execute build.
anka run -w /Applications {template} ls -l
- Will pipe the results of ls -l
from the VM's /Applications
directory.
anka run -v . {template} ls
- Will mount the host current directory inside the VM, execute ls
, pipe the results and unmount.
anka run -v . {template} xcodebuild ...
- Will mount the current directory from the developer machine(host) to the VM and execute an xcodebuild
command and pipe the results back.
anka run sudo ...
- Executes commands inside the VM with sudo
privileges. For instance:
anka run {template} cp -R simpledir /Users/anka
- Will copy the current host directory to the VM at /Users/anka location
anka run -n sierrav40c1 xcodebuild -sdk iphonesimulator -scheme Kickstarter-iOS build
- Will not mount the current host directory and execute build in the VM current directory
You can write parameters to VM configuration so they're available on execution with anka run
using the anka modify
command.
anka run
doesn't support TTY mode, but you could easily use POSIX streams as with regular bash tool:
anka run -n VNMANE whoami > /dev/null
cat file.txt | anka run -n {template} md5
anka view
> sudo anka view --help
Usage: anka view [OPTIONS] VM_ID
Open VM display viewer
Options:
-d, --display INTEGER Specify the displays to view
-s, --screenshot Make png screenshot
-c, --click TEXT Send the pointer event
--help Show this message and exit.
❯ sudo anka start 10.15.4
+-----------------------+-------------------------------------------------------------------+
| uuid | c0847bc9-5d2d-4dbc-ba6a-240f7ff08032 |
+-----------------------+-------------------------------------------------------------------+
| name | 10.15.4 (base:port-forward-22:brew-git:jenkins:openjdk-1.8.0_242) |
+-----------------------+-------------------------------------------------------------------+
| created | Apr 16 16:17 |
+-----------------------+-------------------------------------------------------------------+
| cpu_cores | 2 |
+-----------------------+-------------------------------------------------------------------+
| ram | 4G |
+-----------------------+-------------------------------------------------------------------+
| display | 1 |
+-----------------------+-------------------------------------------------------------------+
| hard_drive | 80Gi (16.6Gi on disk) |
+-----------------------+-------------------------------------------------------------------+
| addons_version | 2.2.2.116 |
+-----------------------+-------------------------------------------------------------------+
| status | running |
+-----------------------+-------------------------------------------------------------------+
| vnc_connection_string | vnc://:admin@192.168.0.107:5900 |
+-----------------------+-------------------------------------------------------------------+
> sudo anka view 10.15.4
You should now see the Anka Viewer window:
You can set the resolution of the Viewer using
sudo anka modify 10.15.4 set display -r 1200x800
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.