DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Alibaba Cloud Toolbox — Running CLI in Docker

Alibaba Cloud Toolbox — Running CLI in Docker

One of the main advantages of containerization is launching applications within their own environments. Check out how to do this with Docker.

Leona Zhang user avatar by
Leona Zhang
·
Aug. 19, 18 · Tutorial
Like (1)
Save
Tweet
Share
4.46K Views

Join the DZone community and get the full member experience.

Join For Free

The Alibaba Cloud Command Line Interface (CLI) is a unified tool to manage your Alibaba Cloud services. With just one tool to download and configure, you can control multiple Alibaba Cloud services from the command line and automate them through scripts.

The CLI uses the SDK of various products internally to achieve the intended results. This installation can be hard to maintain considering the frequent releases of new SDK versions. This can also be cumbersome if you don't have access to a machine with the prerequisites installed.

Docker comes in handy in this situation. The key benefit of Docker is that it allows users to package an application with all its dependencies into a standardized unit for software development. Unlike virtual machines, containers do not have the high overhead and hence enable more efficient usage of the underlying system and resources.

This document explains a pre-packaged Alibaba Cloud CLI Docker image that could be used to launch the CLI at will. It also discusses a way to make the container data persistent.

Prerequisites

  1. A machine with Docker installed. If you don't know how to do this, please refer to this tutorial.
  2. A working internet connection.

Getting Started

To get started, the Alibaba Cloud CLI Docker image needs to be fetched. Depending on your use case run one of the commands below (this will also fetch the latest image if one had not been fetched earlier):

Interactive Mode:

docker run -ti aliyunca/aliyuncli-python-toolbox:latest sh


Detached Mode:

docker run -dti aliyunca/aliyuncli-python-toolbox:latest sh


For both of these invocations, the CLI must then be configured:

# configure the CLI

$ aliyuncli configure

Aliyun Access Key ID [None]: my_access_id

Aliyun Access Key Secret [None]: mypassword

Default Region Id [None]:

Default output format [None]:

# make calls to Aliyun!

$ aliyuncli ecs

usage: aliyuncli <command> <operation> [options and parameters]

[ecs] valid operations as follows:

ActivateRouterInterface               | AddTags  

AllocateEipAddress                     | AllocatePublicIpAddress

ApplyAutoSnapshotPolicy          | AssociateEipAddress

AssociateHaVip                          | AttachDisk

....



# get some help regarding the function

aliyuncli ecs DescribeImages help


Note: The Docker image can be configured to have the initial CLI configuration to be persisted. This should only be done in computers that the user has trust in. The parameter highlighted needs to be replaced.

Run the below command to pass the local folder reference that will store the CLI parameters

docker run -dti \

      -v {Full local folder path}:/root/.aliyuncli \

      aliyunca/aliyuncli-python-toolbox:latest sh

Environmental variables are also honored:

docker run -dti \

      --env ALI_ACCESS_KEY={API Key} \

      --env ALI_ACCESS_SECRET={API Secret} \

      --env ALI_DEFAULT_REGION=ap-southeast-1 \

      --env ALI_OUTPUT_FORMAT=json \

      aliyunca/aliyuncli-python-toolbox:latest sh

Conclusion

This document explains a simple way to access the Alibaba Cloud CLI without going through the complexities of maintaining an environment on its own. This will also free the host computer from the dependencies that will be installed as part of the CLI installation.

Command-line interface Alibaba Cloud Docker (software) Cloud

Published at DZone with permission of Leona Zhang. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Choosing the Right Framework for Your Project
  • Building a RESTful API With AWS Lambda and Express
  • Using GPT-3 in Our Applications
  • Test Execution Tutorial: A Comprehensive Guide With Examples and Best Practices

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: