dimanche 28 décembre 2014

Unable to create anything within a docker container on ec2

I currently have a docker image deployed to amazon's ec2 with elastic beanstalk. It does not allow me to create any files within the docker container.


When I run this image locally, it works great but on EC2, I am unable to persist anything inside the container. This prevents me from creating the puma socket I need to run the server.


Am I missing anything?



[ec2-user@ip-0-0-0-0 ~]$ sudo docker run -t ericraio/app-web
03:52:29 web.1 | started with pid 10
03:52:29 nginx.1 | started with pid 11
03:52:30 web.1 | Puma starting in single mode...
03:52:30 web.1 | * Version 2.10.2 (ruby 2.1.5-p273), codename: Robots on Comets
03:52:30 web.1 | * Min threads: 0, max threads: 16
03:52:30 web.1 | * Environment: production
03:52:31 web.1 | * Listening on unix:///app/tmp/sockets/puma.sock
03:52:31 web.1 | /usr/local/bundle/gems/puma-2.10.2/lib/puma/binder.rb:276:in `initialize': No such file or directory - connect(2) for "/app/tmp/sockets/puma.sock" (Errno::ENOENT)
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/lib/puma/binder.rb:276:in `new'
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/lib/puma/binder.rb:276:in `add_unix_listener'
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/lib/puma/binder.rb:119:in `block in parse'
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/lib/puma/binder.rb:82:in `each'
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/lib/puma/binder.rb:82:in `parse'
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/lib/puma/runner.rb:119:in `load_and_bind'
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/lib/puma/single.rb:78:in `run'
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/lib/puma/cli.rb:507:in `run'
03:52:31 web.1 | from /usr/local/bundle/gems/puma-2.10.2/bin/puma:10:in `<top (required)>'
03:52:31 web.1 | from /usr/local/bundle/bin/puma:16:in `load'
03:52:31 web.1 | from /usr/local/bundle/bin/puma:16:in `<main>'
03:52:31 web.1 | exited with code 1
03:52:31 system | sending SIGTERM to all processes
03:52:31 nginx.1 | exited with code 0


Puma.rb



#!/usr/bin/env puma

# app do |env|
# puts env
#
# body = 'Hello, World!'
#
# [200, { 'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
# end

environment 'production'
daemonize false

app_root = Shellwords.shellescape "#{File.expand_path('../..', __FILE__)}"
# app_root is "/Users/saba/rails projects/test"
#
pidfile "#{app_root}/tmp/pids/puma.pid"
state_path "#{app_root}tmp/pids/puma.state"

# stdout_redirect 'log/puma.log', 'log/puma_err.log'

# quiet
threads 0, 16
bind "http://unix#{app_root}/tmp/sockets/puma.sock"

# ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert }

# on_restart do
# puts 'On restart...'
# end

# restart_command '/u/app/lolcat/bin/restart_puma'
# === Cluster mode ===

# workers 2
# on_worker_boot do
# puts 'On worker boot...'
# end

# === Puma control rack application ===

activate_control_app "http://unix#{app_root}/tmp/sockets/pumactl.sock"


Dockerfile



FROM ruby:2.1.5

#################################
# native libs
#################################

RUN apt-get update -qq
RUN apt-get install -qq -y build-essential
RUN apt-get install -qq -y libpq-dev
RUN apt-get install -qq -y nodejs
RUN apt-get install -qq -y npm
RUN apt-get install -qq -y nginx

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

#################################
# Install Nginx.
#################################

RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
RUN chown -R www-data:www-data /var/lib/nginx
ADD config/nginx.conf /etc/nginx/sites-enabled/default

EXPOSE 80

#################################
# Symlinking Nodejs for ubuntu
# -- http://stackoverflow.com/questions/26320901/cannot-install-nodejs-usr-bin-env-node-no-such-file-or-directory
#################################
RUN ln -s /usr/bin/nodejs /usr/bin/node

#################################
# NPM install globals
#################################

RUN npm install bower -g

#################################
# Rails
#################################

RUN mkdir /app
WORKDIR /app
ADD . /app

ENV RAILS_ENV production
ENV SECRET_KEY_BASE test123

RUN bundle install --without development test
RUN bundle exec rake bower:install
RUN bundle exec rake assets:precompile

CMD foreman start -f Procfile




Aucun commentaire:

Enregistrer un commentaire