Я запускаю приложение rails, которое нужно докеризировать.Приложение состоит из службы rails, службы redis, службы mongodb и службы golang.Я получил код docker-compose для запуска и развертывания.
docker-compose up
вывод
Name Command State Ports
--------------------------------------------------------------------------------------------------
docker_mongo_service_1 /entrypoint.sh mongod Up 0.0.0.0:27017->27017/tcp
docker_redis_service_1 docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
koala_ingest_root ./runIngest Up 0.0.0.0:4001->4001/tcp
koala_rails_root rails s Up 3000/tcp, 0.0.0.0:4000->4000/tcp
Как видно, приложение развертывается, но когда я захожу в браузер для доступа к приложению, страница никогда не разрешается.
IЯ попытался просмотреть журналы, чтобы узнать, смогу ли я определить что-нибудь, что выделяется, может быть, причина того, что приложение не решается.
вот вывод журнала, когда я запускаю docker-compose up
docker-compose up
Creating network "docker_testnet" with the default driver
Creating docker_mongo_service_1 ... done
Creating docker_redis_service_1 ... done
Creating koala_ingest_root ... done
Creating koala_rails_root ... done
Attaching to docker_mongo_service_1, docker_redis_service_1, koala_ingest_root, koala_rails_root
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=46702367ecbf
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] db version v3.2.0
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] git version: 45d947729a0315accb6d4f15a6b06be6d9c19fe7
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] allocator: tcmalloc
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] modules: none
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] build environment:
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] distmod: debian71
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] distarch: x86_64
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] target_arch: x86_64
mongo_service_1 | 2019-09-23T16:43:24.888+0000 I CONTROL [initandlisten] options: {}
mongo_service_1 | 2019-09-23T16:43:24.893+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
mongo_service_1 | 2019-09-23T16:43:24.893+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=8G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
mongo_service_1 | 2019-09-23T16:43:25.253+0000 I CONTROL [initandlisten]
mongo_service_1 | 2019-09-23T16:43:25.253+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
mongo_service_1 | 2019-09-23T16:43:25.253+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
mongo_service_1 | 2019-09-23T16:43:25.253+0000 I CONTROL [initandlisten]
mongo_service_1 | 2019-09-23T16:43:25.254+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
mongo_service_1 | 2019-09-23T16:43:25.254+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
mongo_service_1 | 2019-09-23T16:43:25.254+0000 I CONTROL [initandlisten]
mongo_service_1 | 2019-09-23T16:43:25.255+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongo_service_1 | 2019-09-23T16:43:25.255+0000 I NETWORK [initandlisten] waiting for connections on port 27017
mongo_service_1 | 2019-09-23T16:43:25.255+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
mongo_service_1 | 2019-09-23T16:43:26.204+0000 I NETWORK [initandlisten] connection accepted from 172.19.0.4:52048 #1 (1 connection now open)
mongo_service_1 | 2019-09-23T16:43:26.213+0000 I NETWORK [initandlisten] connection accepted from 172.19.0.4:52052 #2 (2 connections now open)
redis_service_1 | 1:C 23 Sep 16:43:25.603 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_service_1 | 1:C 23 Sep 16:43:25.603 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=1, just started
redis_service_1 | 1:C 23 Sep 16:43:25.603 # Configuration loaded
redis_service_1 | _._
redis_service_1 | _.-``__ ''-._
redis_service_1 | _.-`` `. `_. ''-._ Redis 4.0.8 (00000000/0) 64 bit
redis_service_1 | .-`` .-```. ```\/ _.,_ ''-._
redis_service_1 | ( ' , .-` | `, ) Running in standalone mode
redis_service_1 | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis_service_1 | | `-._ `._ / _.-' | PID: 1
redis_service_1 | `-._ `-._ `-./ _.-' _.-'
redis_service_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_service_1 | | `-._`-._ _.-'_.-' | http://redis.io
redis_service_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_service_1 | |`-._`-._ `-.__.-' _.-'_.-'|
redis_service_1 | | `-._`-._ _.-'_.-' |
redis_service_1 | `-._ `-._`-.__.-'_.-' _.-'
redis_service_1 | `-._ `-.__.-' _.-'
redis_service_1 | `-._ _.-'
redis_service_1 | `-.__.-'
redis_service_1 |
redis_service_1 | 1:M 23 Sep 16:43:25.605 # Server initialized
redis_service_1 | 1:M 23 Sep 16:43:25.605 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_service_1 | 1:M 23 Sep 16:43:25.605 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_service_1 | 1:M 23 Sep 16:43:25.605 * Ready to accept connections
koala_ingest_root | To run in debug mode, run with '-d true' option
koala_ingest_root |
koala_ingest_root | time="2019-09-23T16:43:26Z" level=info msg="Logging in INFO mode"
koala_ingest_root | time="2019-09-23T16:43:26Z" level=info msg="Go version go1.7.3"
koala_ingest_root | time="2019-09-23T16:43:26Z" level=info msg="Starting ingest service on port 4001"
koala_ingest_root | time="2019-09-23T16:43:26Z" level=info msg="Koala Version Number: v19.29.0"
koala_ingest_root | time="2019-09-23T16:43:26Z" level=error msg="Unable to start messaging client: dial tcp 172.19.0.3:6379: getsockopt: connection refused"
koala_ingest_root | [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
koala_ingest_root | - using env: export GIN_MODE=release
koala_ingest_root | - using code: gin.SetMode(gin.ReleaseMode)
koala_ingest_root |
koala_ingest_root | [GIN-debug] GET /status --> main.serverStatusHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/jira/active --> ingest/jira.AllActiveIngestsHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/jira/features --> ingest/jira.AllFeaturesIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/jira/features/team/:team --> ingest/jira.TeamFeaturesIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/jira/program/:program/:team/:type --> ingest/jira.ProgramTeamEpicsIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/jira/team/:team/sprint/:sprint --> ingest/jira.SingleIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/jira/statuses --> ingest/jira.JiraStatusesIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/jira/team/:team/sprints --> ingest/jira.AllSprints (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/updateExternalFeatures/:program --> ingest/jira.UpdateExternalFeatures (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/updateExternalFeaturesFromJira/:program --> ingest/jira.UpdateExternalFeaturesFromJira (3 handlers)
koala_ingest_root | [GIN-debug] GET /ingest/status --> ingest/jira.CheckIngestStatus (3 handlers)
koala_ingest_root | [GIN-debug] POST /jira/team/:team/status --> ingest/jira.CheckTeamJiraStatus (3 handlers)
koala_ingest_root | [GIN-debug] POST /jira/program/:program/status --> ingest/jira.CheckProgramJiraStatus (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/jira/external/epics/:program --> ingest/jira.ProgramIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/spreadsheet --> ingest/spreadsheet.SingleIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/spreadsheet/errors --> ingest/spreadsheet.SingleIngestErrorHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/external/features/:program/:type --> ingest/spreadsheet.ExternalFeatureIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/backlog/team/:team --> ingest/spreadsheet.SingleBacklogIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/fte --> ingest/spreadsheet.SingleFTEIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /ingest/finance --> ingest/spreadsheet.FinancialIngestHandler (3 handlers)
koala_ingest_root | [GIN-debug] POST /spreadsheet/update/:program/:team/epics/:type --> ingest/spreadsheet.TeamEpicsUpdateHandler (3 handlers)
koala_ingest_root | [GIN-debug] Listening and serving HTTP on :4001
koala_rails_root | => Booting Puma
koala_rails_root | => Rails 5.1.5 application starting in development
koala_rails_root | => Run `rails server -h` for more startup options
koala_rails_root | Puma starting in single mode...
koala_rails_root | * Version 3.12.1 (ruby 2.3.8-p459), codename: Llamas in Pajamas
koala_rails_root | * Min threads: 5, max threads: 5
koala_rails_root | * Environment: development
koala_rails_root | * Listening on tcp://localhost:4000
koala_rails_root | Use Ctrl-C to stop
Просто чтобы сообщить, что ingest_root - это служба golang.
Ничто для меня не выделялось, кроме этой части
koala_ingest_root | time="2019-09-23T16:43:26Z" level=error msg="Unable to start messaging client: dial tcp 172.19.0.3:6379: getsockopt: connection refused"
Я не уверен, о чем идет речь.
Вот мой файл docker-compose.yml для большего контекста
version: "3"
volumes:
data:
external:
name: ${MONGO_VOLUME_NAME}
services:
rails:
build:
context: ../rails
container_name: koala_rails_${USER}
environment:
- KOALA_ENV
- RAILS_PORT
- KOALA_INGEST_URL=${INGEST_PROTOCOL}://ingest:${INGEST_PORT}
- KOALA_MONGO_URL=mongo_service:27017
- KOALA_REDIS_URL=redis_service:6379
- KOALA_PKI_IN_DEV
- KOALA_USER_ID_HEADER
- USER
- USERNAME
- KOALA_REGISTER_USER_URL
- KOALA_SECURITY_VALIDATOR_URL
- CERT_FILE_PEM=/usr/src/app/certs/public.pem
- PRIVATE_CERT_FILE_PEM=/usr/src/app/certs/private-key.pem
- SSL_CA_FILE=/usr/src/app/certs/ca.pem
- LOGNAME
- KOALA_SECRET_KEY_BASE
- KOALA_MONGO_USERNAME
- KOALA_MONGO_PASSWORD
- KOALA_HELP_URL
- KOALA_CONTACT_EMAIL
- KOALA_USE_CERTS
- BUNDLE_GEMFILE
- KOALA_SERVER_URL
- RAILS_SERVE_STATIC_FILES
- RAILS_LOG_TO_STDOUT
ports:
- "${RAILS_PORT}:${RAILS_PORT}"
volumes:
- ${CERT_FILE_PEM}:/usr/src/app/certs/public.pem
- ${PRIVATE_CERT_FILE_PEM}:/usr/src/app/certs/private-key.pem
- ${SSL_CA_FILE}:/usr/src/app/certs/ca.pem
links:
- mongo_service
- redis_service
- ingest
depends_on:
- mongo_service
- redis_service
mongo_service:
build:
context: ../db
volumes:
- data:/data/db
ports:
- "27017:27017"
#to do: run redis and check the logs to confirm that ran correctly. The redis image provided by dockerhub is inconsistent and can randomly fail at launch sometimes
redis_service:
build:
context: ../db/redis
restart: always
privileged: true
sysctls:
- net.core.somaxconn=511
ports:
- "6379:6379"
ingest:
build:
context: ../go
container_name: koala_ingest_${USER}
extra_hosts:
- csie.as.northgrum.com:10.8.131.12
environment:
- KOALA_ENV
- KOALA_CONFIG_FILE=/go/config.yml
- INGEST_PORT
- LOGNAME
- KOALA_JIRA_URL
- KOALA_JIRA_SESSION_URL
- CERT_FILE_PEM=/go/certs/public.pem
- PRIVATE_CERT_FILE_PEM=/go/certs/private-key.pem
- SSL_CA_FILE=/go/certs/ca.pem
- KOALA_REDIS_URL=redis_service:6379
- KOALA_MONGO_URL=mongo_service:27017
- KOALA_USE_CERTS
- KOALA_MONGO_USERNAME
- KOALA_MONGO_PASSWORD
- JIRA_USERNAME
- JIRA_PASSWORD
ports:
- "${INGEST_PORT}:${INGEST_PORT}"
volumes:
- ${CERT_FILE_PEM}:/go/certs/public.pem
- ${PRIVATE_CERT_FILE_PEM}:/go/certs/private-key.pem
- ${SSL_CA_FILE}:/go/certs/ca.pem
links:
- mongo_service
depends_on:
- redis_service
Вот мой рельс Dockerfile
# This Dockerfile builds rails image in the docker-composefile
FROM ruby:2.3.8
# installs rails dependencies and gems
WORKDIR /usr/src/app
COPY . .
RUN apt-get update -qq && apt-get install -y build-essential nodejs
COPY Gemfile* ./
RUN gem install bundler
RUN bundle install
EXPOSE 3000
CMD ["rails", "s"]
и это мой гемфайл для рельсов
source ENV["KOALA_GEM_SERVER"] || 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.1.5'
gem 'angularjs-rails', '1.5.8'
gem 'bootstrap-sass', '3.3.7'
gem 'coffee-rails', '~> 4.2.0'
gem 'cp-sparrow', '0.0.16'
gem 'font-awesome-rails', '4.7.0.4'
gem 'httparty', '0.14.0'
gem 'jquery-rails'
gem 'momentjs-rails', '2.15.1'
gem 'mongoid', '6.0.2'
gem 'oj', '2.17.4'
gem 'puma', '~> 3.0'
gem 'redis', '4.0.1'
gem 'responders', '2.4.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '4.1.20'
gem 'underscore-rails', '1.8.3'
gem 'rails-controller-testing'
gem 'railties', '5.1.5'
group :development do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
gem 'listen', '~> 3.0.5'
gem 'teaspoon-jasmine', '2.3.4'
gem 'teaspoon', '1.1.5'
#gem 'web-console'
end
group :test do
gem 'rspec', '3.5.0'
gem 'rspec_junit_formatter', '0.2.3'
gem 'rspec-rails', '3.5.2'
gem 'simplecov'
gem 'simplecov-rcov'
gem 'selenium-webdriver'
end
group :assests do
gem 'bootstrap-modal-rails'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Я думаю, что есть что-то незначительное, что я мог бы пропустить, учитывая фактическое составление приложения.Есть идеи?