BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Docker Now on AWS Cloudshell

Docker Now on AWS Cloudshell

This item in japanese

AWS recently announced that AWS CloudShell now provides access to Docker Engine for its users. With this integration, containers can be locally prototyped and pushed to registries prior to deploying them on AWS.

AWS CloudShell is a web-based shell for command-line access to resources in an AWS environment. Accessed via the AWS Console and pre-authenticated with the same credentials, it allows users to execute AWS CLI commands for ad-hoc or repeat tasks. In addition to the AWS CLI, it includes a variety of common development and operational tools to facilitate rapid prototyping and experimentation. The Docker Engine is the latest addition to its list of pre-installed tools.

Sample Docker command running in AWS CloudShell (Source: AWS CloudShell tutorial)

Launched in late 2020 to the welcome of the developer community, AWS CloudShell presented a simpler and cheaper alternative to AWS’s web-based Integrated Development Environment (IDE), AWS Cloud 9, for command-line administrative tasks. Where AWS Cloud 9 required the provisioning of an EC2 instance, AWS CloudShell offered 1 vCPU, 2GB of RAM and 1GB of persistent storage between sessions free of charge. This, along with the pre-installed tools ranging from kubectl, the kubernetes control plane cli, to Boto3, the AWS SDK for Python, made it a good fit for operational maintenance tasks and interactive development. Combining Docker with the AWS CDK or the AWS CLI , both of which are preinstalled on AWS CloudShell, opens two new avenues for infrastructure development.

In the first instance, utilising the "DockerImageFunction" and "DockerImageCode" CDK Lambda resources, an AWS Lambda function executing a Docker container can now be deployed from AWS CloudShell.

 

…
const { DockerImageFunction, DockerImageCode } = require('aws-cdk-lib/aws-lambda');
const path = require('path');

…
class DockerTutorialStack extends Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    // define lambda that uses a Docker container
    const dockerfileDir = path.join(__dirname);
    new DockerImageFunction(this, 'DockerTutorialFunction', {
      code: DockerImageCode.fromImageAsset(dockerfileDir),
      functionName: 'DockerTutorialFunction',
    });
  }
}

new DockerTutorialStack(app, 'DockerTutorialStack');

Deploying a CDK Stack referencing a Docker image(Source: AWS CloudShell tutorial)

Alternatively, using the AWS CLI, a Docker image can be built and pushed to a registry for use on AWS ECS, AWS EKS or AWS Lambda, all from AWS CloudShell.

Pushing a docker image to Amazon ECR (Source: AWS CloudShell tutorial)

With the addition of Docker Engine, AWS CloudShell moves closer to feature parity with the equivalent offerings in Azure and GCP. However, the 1GB persistent storage limitation on AWS CloudShell, as opposed to 5GB on GCP or Azure, means that only small containers can be prototyped or built. User @MicheAngeCamhi, sharing his experience on X, remarked:

. . . the local storage is limited to 1 GB, and with docker images this can go out very quickly!

As a matter of fact, my build had grown and now fails for ‘Docker ran out of space’

Finally, support for Docker is currently available in the default AWS CloudShell regions, apart from California, Osaka and Stockholm regions. Further guidance can be found on the AWS CloudShell user guide.

About the Author

Rate this Article

Adoption
Style

BT