J
J
jScheq2017-12-25 14:57:35
Software Deployment
jScheq, 2017-12-25 14:57:35

How to deploy a docker-compose application on a VPS?

Good afternoon.
I have 2 services described in docker-compose.yml:

version: '2'

services:
  php:
    build: php
    ports:
      - "80:80"
    volumes:
      - ./php/www:/var/www/site
    links:
      - db

  db:
    image: mysql:latest
    volumes:
      - /var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_USER=user
      - MYSQL_PASSWORD=password
      - MYSQL_DATABASE=database

On the local machine, I easily create 2 related containers with the command:
docker-compose up -d
And everything works fine. How can I transfer this application to VPS? What's the easiest way to deploy it there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Askhat Bikmetov, 2017-12-25
@askhat

You need to add the remote machine to docker-machine and go to its context.

$ docker-machine create --driver generic \
     --generic-ip-address $REMOTE_IP_OR_HOSTNAME \
     $REMOTE_MACHINE_NAME

$ eval (docker-machine env $REMOTE_MACHINE_NAME)

After that, any docker commands entered locally will be executed on the remote machine.
Links:
  • Driver Documentation
  • generic driver documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question