docker-compose up -H <ssh://host> fails with exec error if the host is raspberry pi 3

I’m using docker-compose on my mac to a rails app. Got this template from https://github.com/adelevie/docker-compose-rails. The app runs fine on my machine, but when I try to deploy the app on a raspberry pi using compose it fails with the error

ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update -qq && apt-get install -y build-essential libpq-dev' returned a non-zero code: 1

My Dockerfile look like

FROM ruby:2.2.0
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
ADD . /myapp

and docker-compose like

version: '2'
services:
  db:
    image: postgres
  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depends_on:
      - db

I think it’s because I’ve a raspberry pi 3 with a linux/arm/v7 (model name : ARMv7 Processor rev 4 (v7l)) architecture that’s causing it to fail but how do I fix it?

Source: StackOverflow