Building Google Cloud Platform Solutions
上QQ阅读APP看书,第一时间看更新

Installing additional tools

For many of the included programming languages, the Cloud Shell comes preconfigured with tools to support multiple versions. The current Java version can be changed via the update-java-alternatives command available from the java-commons package. For Node.js, this can be done using the Node Version Manager command nvm. Python comes with both python for version 2.7.9 and python3 for version 3 support (version 3.4.2 at the time of writing). In addition, the Cloud Shell VM includes virtualenv for managing Python dependency versioning on a per-service basis.

While many tools and languages are included out of the box, there may be times you need to bring additional tools into your Cloud Shell VM. Because everything outside of the $HOME directory will be lost after a short period of inactivity, installing new tools outside of $HOME is not a great idea. This issue affects many of the commonly used installation procedures such as apt-get.

There are a couple of ways around this, such as creating an install script to reinstall needed binaries. Another option is to install binaries directly in $HOME/bin, which will be automatically added to your system path. A third and often easier way to bring in additional tools is to leverage the included docker tools to pull and run Docker images as needed. Files and folders inside the $HOME directory can then be mounted as volumes to persist container data across sessions, as shown in the following screenshot:

Using Docker to execute Groovy commands in the Cloud Shell without installing Groovy locally