Alibaba Cloud Command Line Interface (CLI) is a tool used to manage and use Alibaba Cloud resources on a command-line interface. Alibaba Cloud CLI is written in Go and built on Alibaba Cloud APIs. This topic describes how to run Alibaba Cloud CLI in a Docker container.


Docker 18.09 or later is installed on your local computer.


  1. Create a directory on the desktop or anywhere on your local computer. Save the following code to a plaintext file named Dockerfile:
    FROM alpine:latest
    # Add the jq tool for displaying command output in the JSON format.
    RUN apk add --no-cache jq
    # Obtain and install Alibaba Cloud CLI.
    RUN wget
    RUN tar -xvzf aliyun-cli-linux-3.0.2-amd64.tgz
    RUN rm aliyun-cli-linux-3.0.2-amd64.tgz
    RUN mv aliyun /usr/local/bin/
    Note A Dockerfile must be named Dockerfile, which starts with the uppercase letter D and has no file name extension. Only one Dockerfile can be saved in each directory.
  2. Run the docker build --tag aliyuncli. command in the created directory. The command is used to build a Docker image named aliyuncli.
    Note The period (.) at the end of the command instructs Docker to build a Docker image in the current directory. If the period (.) is omitted, an error occurs.
  3. After you create the Docker image, run the following command to start a Docker container:
    docker run -it -d -–name aliyuncli aliyuncli
    Note In the command, the first aliyuncli is the container name, which can be customized. The second aliyuncli is the image name, which must be the same as the name of the image that you want to use. In this example, the image is named aliyuncli in the previous step.
  4. Run the following command to connect to the Docker container:
    docker exec -it aliyuncli /bin/sh