Docker Community Forums

Share and learn in the Docker community.

How to use docker-compose with swarm without machine


(Partsalliance) #1

Morning,

I have set up docker swarm and it is wonderful. I also have used docker-compose and it is wonderful too. However I am unable to work out how to get them to work together without Machine. I am using swarm on a fixed number of VMs so do not need or want to use machine currently. Using docker 1.7.1 and swarm 0.4.0 and compose 1.4.2.

My question is how to do I run a docker-compose up command on my swarm master? Currently I can only execute docker commands on my swarm master and docker-compose does not have -H flag to point to the master.

Patrick


(Ranjandas) #2

Hi,

You should set the DOCKER_HOST and related variables before using docker-compose. Docker compose reads these variables and will talk to the docker/swarm master.

If you already have configured your swarm cluster with Docker Machine you can make use of machine to set those environment variables for you.

eval $(docker-machine env --swarm swarm-master)
# where swarm-master is the name of the swarm-master machine
# you can get the machine name by using
docker-machine ls

Also make sure the run docker-compose from the same terminal where you ran the eval command.

Regards