Containers on Compute Engine

Software containers are a convenient way to run your applications in multiple isolated user-space instances. You can run containers on either Linux or Windows Server 2016 public VM images. Containers allow your applications to run with fewer dependencies on the host virtual machine and run independently from other containerized applications that you deploy to the same virtual machine instance. These characteristics make containerized applications more portable, easier to deploy, and easier to maintain at scale.

This document describes some of the more common container technologies that you can use to run containers on Compute Engine instances. You can use these technologies on most of the public VM images that Google Compute Engine provides.

Run containers on Compute Engine when you need complete control over your container environment and your container orchestration tools. Alternatively, you can use Google Container Engine to simplify cluster management and container orchestration tasks so that you do not need to manage the underlying virtual machine instances.

Container technologies that run on Compute Engine

In general, Compute Engine instances can run almost any container technology or tool. You can run several different types of containers on modern Linux operating systems and you can also run Docker on Windows Server 2016. The following list includes several common tools that you can use to run and manage containerized applications:

  • Docker and rkt are two popular container technologies that allow you to easily run containerized applications.
  • Kubernetes is a container orchestration platform that you can use to manage and scale your running containers across multiple instances or within a hybrid-cloud environment.
  • You can convert your existing systems into LXD images and run them within Compute Engine virtual machine instances for a simple lift-and-shift migration solution. LXD runs on Ubuntu images.

Additionally, you can use Container Registry, to manage container image versions. Container Registry serves as a central location to store and manage your container images before you deploy those images to Kubernetes on Compute Engine or to Google Container Engine clusters.

Container-optimized VM images

Compute Engine provides several public VM images that you can use to create instances and run your container workloads. Some of these public VM images have a minimalistic container-optimized operating system that includes newer versions of Docker, rkt, or Kubernetes preinstalled. The following public image families are designed specifically to run containers:

  • Container-Optimized OS from Google
    • Includes: Docker, Kubernetes
    • Image project: cos-cloud
    • Image family: cos-stable
  • CoreOS
    • Includes: Docker, rkt, Kubernetes
    • Image project: coreos-cloud
    • Image family: coreos-stable
  • Ubuntu
    • Includes: LXD
    • Image project: ubuntu-cloud-os
    • Image family: ubuntu-1604-lts

If you need to run specific container tools and technologies on images that do not include them by default, install those technologies manually.

Installing container technologies on your instances

When you run container workloads on Compute Engine, you have the freedom to employ whatever container technologies and orchestration tools that you need. Create an instance from a public VM image and then install the container technologies that you want. For example:

In some situations, you might require specific versions of these technologies to ensure that they operate together correctly. For example, Kubernetes usually runs best with specific versions of Docker. Typically, you can install the latest versions of these technologies for the best result.

Installing Docker on Windows Server 2016 images

You can install Docker on Windows Server 2016 images and run containerized applications in a Windows environment. If you do not have a Windows Server 2016 instance, you can create a Windows Server instance using a Windows Server 2016 public image.

  1. Connect to the Windows Instance.

  2. Open a PowerShell terminal as an administrator.

  3. Set the *RscIPv4 parameters to zero:

    PS C:> netsh netkvm setparam 0 *RscIPv4 0
    

  4. Restart netkvm:

    PS C:> netsh netkvm restart 0
    

  5. If your connection to Windows stops, reconnect to the instance.

  6. Install Docker from the Microsoft repositories:

    PS C:> Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
    

    PS C:> Install-Package -Name docker -ProviderName DockerMsftProvider
    

  7. Restart the instance:

    PS C:> Restart-Computer -Force
    

After the instance restarts, you can use it to run Docker containers. If you are unable to connect to the instance after it restarts, you might need to set the correct MTU for your instance.

Troubleshooting RDP connections after configuring the Docker network

When you create a container network on your Windows instance using the docker network create ... or New-VMSwitch commands, the MTU of the network interface might be forced to 1500. If this happens, your RDP session might stop and you might be unable to reconnect because Google Cloud Platform supports only a maximum MTU of 1460. To recover from this situation, run the following commands in a PowerShell or a cmd shell to see your interface names and reset the MTU:

PS C:\> netsh interface ipv4 show subinterfaces
   MTU  MediaSenseState   Bytes In  Bytes Out  Interface
------  ---------------  ---------  ---------  -------------
4294967295                1          0       5720  Loopback Pseudo-Interface 1
  1500                1      76091     292077  vEthernet (HNSTransparent)
PS C:\> netsh interface ipv4 set subinterface "vEthernet (HNSTransparent)" mtu=1460 store=persistent

If you are unable to run these commands because you can no longer connect to your instance via RDP, you can can connect to the instance through the serial console, start a cmd prompt and run the netsh commands there to repair the MTU. To avoid having to do this you can execute the docker network ... or New-VMSwitch commands as part of a script that also executes the MTU repair commands.

What's next

Send feedback about...

Compute Engine Documentation