Populating docker-machine with docker-compose

Viewed 1031

Edit How can I start containers on a docker-machine with docker compose?

I have provisioned 3 docker machines and joined two as workers to one master machine. However, none of my code or services seem to be present in the machine. How can I run a docker-compose file on a docker machine?

Normally in development I run docker-compose up. However, docker-compose is unavailable on the box. I'm not sure at what point the machine starts running the docker containers or how that can be done. I passed the docker-compose.prod.yml as part of the creating the stack. echo docker stack deploy -c docker-compoe.prod.yml app.

Very new to all of this coming from Heroku. Just wondering if the only way to do this is to ssh into every box and manually copy files over.

I would expect to be able to docker-machine ssh host. And then inside of that shell be able to docker-compose up.

If it's true that I have to manually rsync all of the dirs over, I'm curious what the stack actually does?

Edit

version: "3"

services:
  api:
    image: "api"
    command: rails server -b "0.0.0.0" -e production
    depends_on:
      - db
      - redis
    deploy:
      replicas: 3
      resources:
        cpus: "0.1"
        memory: 50M
      restart_policy:
        condition: on-failure
    env_file:
      - .env-prod
    networks:
      - apinet
    ports:
      - "3000:3000"
  client:
    image: "client"
    depends_on:
      - api
    deploy:
      restart_policy:
        condition: on-failure
    env_file:
      - .env-prod
    networks:
      - apinet
      - clientnet
    ports:
      - "4200:4200"
      - "35730:35730"
  db:
    deploy:
      placement:
        constaints: [node.role == manager]
      restart_policy:
        condition: on-failure
    env_file: .env-prod
    image: mysql
    ports:
      - "3306:3306"
    volumes:
      - ~/.docker-volumes/app/mysql/data:/var/lib/mysql/data
  redis:
    deploy:
      placement:
        constaints: [node.role == manager]
      restart_policy:
        condition: on-failure
    image: redis:alpine
    ports:
      - "6379:6379"
    volumes:
      - ~/.docker-volumes/app/redis/data:/var/lib/redis/data
  nginx:
    image: app_nginx
    deploy:
      restart_policy:
        condition: on-failure
    env_file: .env-prod
    depends_on:
      - client
      - api
    networks:
      - apinet
      - clientnet
    ports:
      - "80:80"
networks:
  apinet:
    driver: overlay
  clientnet:
    driver: overlay
1 Answers
Related