Search code examples
dockerfig

Use fig and docker-machine to deploy remotely


I use docker-machine to easily create docker hosts on AWS.

Locally I use fig (or docker-compose) to start the various microservices associated with a service.

Is it possible for fig to use the config variables set by the docker-machine command:

 docker-machine config host

So when I do:

fig up

Fig creates the service on the host set by docker-machine and not the local one?


Solution

  • I haven't tried to do this with a remote host but I have it working with a vmwarefusion based machine. Because fig respects some of the DOCKER_ environment variables you can modify them to point to your docker host. Try something like this:

    $(docker-machine env host); docker-compose up
    

    Edited previous approach (referenced in comments):

    #!/bin/bash
    
    # modify path and host with output from > docker-machine config host
    DOCKER_CERT_PATH=~/.docker/machines/.client/
    DOCKER_HOST=tcp://172.16.124.216:2376
    DOCKER_TLS_VERIFY=1
    
    fig up