Using DockerMachine with 3DS OUTSCALE

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 virtual machines (VMs) on the OUTSCALE Cloud. 3DS OUTSCALE being an Amazon EC2 API compatible Cloud provider, using this driver is very easy.

  1. Create the VM 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 a public IP with your newly created VM as, for now, 3DS OUTSCALE does not support automatic association of a public IP with a RunInstance API call. For more information, see Linking a Public IP with a VM or a Network Interface.

  3. Once the VM has been created 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 VM 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

    Screen Shot 2017 05 09 at 5.50.15 PM

    Do not forget to open your security groups accordingly whenever you expose your Docker Host ports. For more information, see Adding Rules to a Security Group.

Related Pages