Docker ruby container error

Issue type
Hi, Iḿ trying to follow the quick guide Docker+Ruby(https://docs.docker.com/compose/rails/#build-the-project), but I am unable to finish it due to an error.

OS Version/build
NAME="Ubuntu"
VERSION=“14.04.5 LTS, Trusty Tahr”

docker-compose version 1.18.0, build 8dd22a9
docker-py version: 2.6.1
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t 3 May 2016

Client:
Version: 17.09.1-ce
API version: 1.32
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:24:48 2017
OS/Arch: linux/amd64

Server:
Version: 17.09.1-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:23:29 2017
OS/Arch: linux/amd64
Experimental: false

Dockerfile
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs ruby-dev zlib1g-dev liblzma-dev
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle config build.nio4r --with-cflags="-std=c99"
RUN bundle install
COPY . /myapp

docker-compose.yml
version: '3’
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

Steps to reproduce
Follow the link above to the docker-compose steps and get the following output:

Starting rubydocker_db_1 … done
Building web
Step 1/9 : FROM ruby:2.3.3
—> 0e1db669d557
Step 2/9 : RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs ruby-dev zlib1g-dev liblzma-dev
—> Using cache
—> 1f450abd6152
Step 3/9 : RUN mkdir /myapp
—> Using cache
—> 53a9989657a3
Step 4/9 : WORKDIR /myapp
—> Using cache
—> af6937154d68
Step 5/9 : COPY Gemfile /myapp/Gemfile
—> Using cache
—> d6769d7253c7
Step 6/9 : COPY Gemfile.lock /myapp/Gemfile.lock
—> Using cache
—> 58df70e606b5
Step 7/9 : RUN bundle config build.nio4r --with-cflags="-std=c99"
—> Running in 3573638c9305
—> db4580d52dcc
Removing intermediate container 3573638c9305
Step 8/9 : RUN bundle install
—> Running in 09699a1c32fb
Fetching gem metadata from https://rubygems.org/
Fetching version
Fetching dependency
Resolving dependencies…
Installing rake 12.3.0
Installing concurrent-ruby 1.0.5
Installing minitest 5.10.3
Installing thread_safe 0.3.6
Installing builder 3.2.3
Installing erubis 2.7.0
Installing mini_portile2 2.3.0
Installing crass 1.0.3
Installing rack 2.0.3
Installing nio4r 1.2.1 with native extensions
Installing websocket-extensions 0.1.3
Installing mini_mime 1.0.0
Installing arel 7.1.4
Using bundler 1.14.6
Installing method_source 0.9.0
Installing thor 0.20.0
Installing i18n 0.9.1
Installing tzinfo 1.2.4
Installing nokogiri 1.8.1 with native extensions
Installing rack-test 0.6.3
Installing sprockets 3.7.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /usr/local/bundle/gems/nio4r-1.2.1/ext/nio4r
/usr/local/bin/ruby -r ./siteconf20171221-5-1xyw7b.rb extconf.rb
–with-cflags=-std=c99
Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20171221-5-1xyw7b.rb
extconf.rb --with-cflags=-std=c99 2>&1

Gem files will remain installed in /usr/local/bundle/gems/nio4r-1.2.1 for
inspection.
Results logged to
/usr/local/bundle/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/gem_make.out

An error occurred while installing nio4r (1.2.1), and Bundler cannot continue.
Make sure that gem install nio4r -v '1.2.1' succeeds before bundling.
ERROR: Service ‘web’ failed to build: The command ‘/bin/sh -c bundle install’ returned a non-zero code: 5

Can anybody help me please?

it complains about “Cannot allocate memory”…did you try to execute your docker-/compose files on play-with-docker.com?

Yes, It works, but why I can’t make it work on my local?

can you try it with more RAM?