You can use Docker Machine to:

  • Install and run Docker on a Mac or Windows
  • Provision and manage multiple remote Docker hosts
  • Provision Swarm clusters

For more information about Docker Machine, see Docker Machine official documentation - Overview.

Requirements

Use Case

For the purpose of this tutorial, we leverage AmazonEC2 Driver to create Docker Host VMs on Outscale Cloud. Outscale being an Amazon EC2 API compatible Cloud provider, using this driver is very easy.


  1. Launch the instance using the following command:

    We recommend to use an Ubuntu OMI in order to make it work seamlessly with the guidelines below.


    $> docker-machine create -d amazonec2 \
    	--amazonec2-ami ami-8a6a0120 \
    	--amazonec2-vpc-id <vpc_id> \
    	--amazonec2-region "eu-west-2" \
    	--amazonec2-zone "eu-west-2a" \
    	--amazonec2-subnet-id <subnet_id> \
    	--amazonec2-ssh-user root \
        --amazonec2-endpoint https://fcu.eu-west-2.outscale.com
     Outscale-Docker-Sandbox

    Most of the options have an equivalent with an environment variable. For more information, see Docker Machine official documentation.

  2. Associate an External IP address (EIP) with your newly created instance as, for now, Outscale does not support automatic association of an EIP with a RunInstance API call. For more information, see Associer une EIP à une instance ou à une interface réseau.

  3. Once the instance has been launched and SSH is available, docker-machine will provision all the elements needed to install and configure your Docker host. To view all your docker hosts, use the following command:

    $> docker-machine ls
    NAME                  		ACTIVE   	DRIVER      STATE     URL                        	SWARM   	DOCKER    		ERRORS
    Outscale-Docker-Sandbox   	*    		amazonec2   Running   tcp://171.33.120.182:2376        			v17.05.0-ce
  4. Point the Docker client from your instance to your Docker host using the following command:

    $> eval "$(docker-machine env Outscale-Docker-Sandbox)"

    To check your new set of environment variables, use the following command:

    $> env | grep DOCKER
    DOCKER_TLS_VERIFY=1
    DOCKER_HOST=tcp://171.33.120.182:2376
    DOCKER_CERT_PATH=/Users/Gregor/.docker/machine/machines/Outscale-Docker-Sandbox
    DOCKER_MACHINE_NAME=Outscale-Docker-Sandbox
  5. Run Docker containers directly in your Docker host as usual:

    $> docker run -d -p 8000:80 --name webserver kitematic/hello-world-nginx

    Do not forget to open your security groups accordingly whenever you expose your Docker Host ports. For more information, see Ajouter des règles à un security group.



Windows® est une marque déposée de Microsoft Corporation aux Etats-Unis et/ou dans les autres pays.

AWS™ et Amazon Web Services™ sont des marques de commerce d'Amazon Technologies, Inc. ou de ses affiliées aux Etats-Unis et/ou dans les autres pays.

Voir Mentions légales.