Я получаю следующую ошибку при запуске docker run myapp
:
! Unable to load application: SocketError: getaddrinfo: Name or service not
known
bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
Ниже приведены мои конфигурации и файлы Docker:
DockerFile в приложении
FROM ruby:2.5.0
# Set an environment variable where the Rails app is installed to inside of Docker image
ENV RAILS_ROOT /Users/admin/git/generic/myapp
ENV REDIS_URL=redis://redis:6379/0
RUN mkdir -p $RAILS_ROOT
# Set working directory
WORKDIR $RAILS_ROOT
# Setting env up
ENV RAILS_ENV='production'
ENV RACK_ENV='production'
# Adding gems
#COPY ./Users/admin/git/generic/myapp/Gemfile ./Users/admin/git/generic/myapp/app/docker/app/Gemfile
#COPY ./Users/admin/git/generic/myapp/Gemfile.lock ./Users/admin/git/generic/myapp/app/docker/web/Gemfile.lock
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
# Adding project files
COPY . .
RUN gem install bundler
RUN bundle install
COPY . .
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb","production"]
DockerFile в Интернете
FROM nginx
# Install dependencies
RUN apt-get update -qq && apt-get -y install apache2-utils
# establish where Nginx should look for files
ENV RAILS_ROOT /Users/admin/git/generic/myapp
# Set our working directory inside the image
WORKDIR $RAILS_ROOT
# create log directory
RUN mkdir log
# copy over static assets
COPY public public/
# Copy Nginx config template
COPY docker/web/nginx.conf /tmp/docker.nginx
# put the final config in its place
RUN envsubst '$RAILS_ROOT' < /tmp/docker.nginx > /etc/nginx/conf.d/default.conf
EXPOSE 80
# Use the "exec" form of CMD so Nginx shuts down gracefully on SIGTERM (i.e. `docker stop`)
CMD [ "nginx", "-g", "daemon off;" ]
Моя конфигурация Nginx
upstream docker {
server 127.0.0.1:3000;
}
server {
# define your domain
# define the public application root
listen 80;
root $RAILS_ROOT/public;
index index.html;
# define where Nginx should write its logs
access_log $RAILS_ROOT/log/nginx.access.log;
error_log $RAILS_ROOT/log/nginx.error.log;
# send non-static file requests to the app server
location / {
proxy_pass http://docker;
}
}
docker-compose.yml
version: '3'
volumes:
postgres_data: {}
services:
redis:
image: redis
command: redis-server
ports:
- "6379:6379"
app:
build:
context: .
dockerfile: /Users/admin/git/generic/myapp/docker/app/DockerFile
depends_on:
- db
db:
image: postgres
volumes:
- postgres_data:/var/lib/postgresql/data
web:
build:
context: .
dockerfile: /Users/admin/git/generic/myapp/docker/web/DockerFile
depends_on:
- app
ports:
- 80:80
Puma.rb
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'production'
on_worker_boot do
ActiveRecord::Base.establish_connection
end
Может кто-нибудь помочь, как исправить эту ошибку Socket. Локальный хост уже добавлен в мой файл хоста. У меня естьпробовал изменения в конфиге nginx тоже.Тем не менее я сталкиваюсь с той же проблемой.