Configure environment variables
To simplify the parameters that are used each time a Docker Machine command is run, configure the environment variables as follows:
export DEBUG=true export ECS_ACCESS_KEY_ID=<your_access_key_id> export ECS_ACCESS_KEY_SECRET=<your_access_key_secret> export ECS_REGION=<your_ecs_region> export ECS_SSH_PASSWORD=<your_ssh_password> export MACHINE_DOCKER_INSTALL_URL= http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet # Optional for VPC only export ECS_VPC_ID=<your_vpc_id> export ECS_VSWITCH_ID=<your_vswitchid>
Use ECS Driver to create and delete ECS instances
After environment variables are configured, most parameters can be replaced by those environment variables by default.
You can create an ECS instance that contains the Docker environment by running the following command.
docker-machine create -d aliyunecs dev1
The example output is as follows:
$ docker-machine create -d aliyunecs dev1 Running pre-create checks... Creating machine... Waiting for machine to be running, this may take a few minutes... Machine is running, waiting for SSH to be available... Detecting operating system of created instance... Provisioning created instance... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... To see how to connect Docker to this machine, run: docker-machine env dev1
Run the docker-machine ls command to view the created ECS instance that contains the Docker environment.
$ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM dev1 - aliyunecs Running tcp://188.8.131.52:9376
Run the docker-machine kill command to stop the ECS instance and view the instance status.
$ docker-machine kill dev1 $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM dev1 - aliyunecs Stopped tcp://184.108.40.206:9376
Run the docker-machine rm command to delete the ECS instance and view the instance information (you can directly run this command without running the docker-machine kill command first).
$ docker-machine rm dev1 Successfully removed dev1 $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM
For more docker-machine commands, see Docker Machine command-line reference.