¡Hi! I've just developed RoR application to work with MongoDB and works fine. I tried few http requests to the app with postman, also worked fine!
When I deployed the app using Docker, I got a MongoDB error that follows after any request:
MONGODB | Message exceeds allowed max message size. The max is 50331648.
ms_notifications_1 | 2017-09-29 21:16:48 +0000: HTTP parse error, malformed request (): # Puma::HttpParserError: Invalid HTTP format, parsing fails.
I'll be very thankful If anybody have the solution for this error. Thanks!
My compose file:
version: '2'
services:
ms_notifications_db:
image: mongo:latest
container_name: "rancher-node1" `
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/dev/null
volumes:
- ./data/db:/data/db
ports:
- "27017:27017"
command: mongod --smallfiles `
ms_notifications:
build: .
command: bash -c " rm -f tmp/pids/server.pid && bundle
exec rails db:migrate && bundle exec rails s -p 3007 -b '0.0.0.0'"
ports:
- "3007:3007"
depends_on:
- ms_notifications_db
Related
I'm really confused why I'm unable to make API requests to any site. for example, I want to run :
HTTParty.get("https://fakerapi.it/api/v1/persons")
It runs well on my machine. (without docker).
But if I run it inside docker, I got :
SocketError (Failed to open TCP connection to fakerapi.it:443 (getaddrinfo: Name does not resolve))
It happens not only for this site. But for all sites.
So I guess there's something wrong with my docker settings. But I'm not sure where to start.
I'm new to docker. So any advice means a lot to me.
Below is my docker-compose.yaml
version: '3.4'
services:
db:
image: mysql:8.0.17 #using official mysql image from docker hub
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- db_data:/var/lib/mysql
ports:
- "3307:3306"
backend:
build:
context: .
dockerfile: backend-dev.Dockerfile
ports:
- "3001:3001"
volumes:
#the host repos are mapped to the container's repos
- ./backend:/my-project
#volume to cache gems
- bundle:/bundle
depends_on:
- db
stdin_open: true
tty: true
env_file: .env
command: /bin/sh -c "rm -f tmp/pids/server.pid && rm -f tmp/pids/delayed_job.pid && bundle exec bin/delayed_job start && bundle exec rails s -p 3001 -b '0.0.0.0'"
frontend:
build:
context: .
dockerfile: frontend-dev.Dockerfile
ports:
- "3000:3000"
links:
- "backend:bb"
depends_on:
- backend
volumes:
#the host repos are mapped to the container's repos
- ./frontend/:/my-project
# env_file: .env
environment:
- NODE_ENV=development
command: /bin/sh -c "yarn dev --port 3000"
volumes:
db_data:
driver: local
bundle:
driver: local
How I try to run:
docker-compose run backend /bin/sh
rails c
HTTParty.get("https://fakerapi.it/api/v1/persons")
Any idea how can I fix this?
This question already has answers here:
docker: executable file not found in $PATH
(14 answers)
Closed 1 year ago.
I am new to docker. I am trying to containerise my Go application using docker-compose.
Technology used
Golang, Docker 20.10.8 and Air (for live reloading).
My Dockerfile looks like this.
FROM base as dev
WORKDIR /opt/app/api
RUN apk update
RUN apk add git gcc musl-dev
RUN apk add curl
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
# RUN go get
# RUN go mod tidy
CMD ["air"]
My docker-compose.yml is this.
version: "3.9"
services:
app:
build:
dockerfile: Dockerfile.local
context: .
target: dev
container_name: 'server'
volumes:
- .:/opt/app/api
env_file:
- .env
ports:
- "8080:8080"
restart:
always
depends_on:
- db
- rabbitmq
db:
image: postgres:13-alpine
volumes:
- data:/var/lib/postgresql/data
container_name: 'postgres'
ports:
- 5432:5432
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: postgres
rabbitmq:
image: rabbitmq:3-management-alpine
container_name: 'rabbitmq'
ports:
- 5672:5672
- 15672:15672
volumes:
- rabbitmq:/var/lib/rabbitmq
- rabbitmq-log:/var/log/rabbitmq
migrate: &basemigrate
profiles: ["tools"]
image: migrate/migrate
entrypoint: "migrate -database postgresql://thursday:postgres#db/postgres?sslmode=disable -path /tmp/migrations"
command: up
depends_on:
- db
volumes:
- ./migrations:/tmp/migrations
create-migration:
<<: *basemigrate
entrypoint: migrate create -dir /tmp/migrations -ext sql
command: ""
depends_on:
- db
down-migration:
<<: *basemigrate
entrypoint: migrate -database postgresql://thursday:postgres#db/postgres?sslmode=disable -path /tmp/migrations
command: down
depends_on:
- db
volumes:
data:
rabbitmq:
rabbitmq-log:
On running command sudo docker-compose up -d I am getting the following error
Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "air": executable file not found in $PATH: unknown
As mentioned in "docker: executable file not found in $PATH":
When you use the exec format for a command (in your case: CMD ["air"], a JSON array with double quotes) it will be executed without a shell.
This means that most environment variables will not be present.
CMD air should work, provided:
air is an executable (chmod 755)
air was cross-compiled to Linux (unless your host running docker is already Linux)
Here's my docker-compose file. I have a scraper service feeding a rails api (data_api):
version: '3'
services:
redis-server:
image: redis
restart: always
scraper:
image: davidgeismar/artifacts-scraper:without-db
command: "bundle exec rake scrape_sources:scrape\"[['christies'],nil,[2019]]\""
volumes:
- ./logs/artifacts_scraper:/usr/src/artifacts_scraper/log
environment:
- REDIS_URL=redis://redis-server:6379/0
- ARTIFACTS_ENV=docker_development
- DATA_API_BASE=http://data_api:3000
depends_on:
- data_api
- redis-server
data_api:
volumes:
- ./logs/artifacts_data_api:/artifacts_data_api/log
image: davidgeismar/artifacts_data_api:latest
command: 'rails server -b 0.0.0.0'
environment:
- RAILS_ENV=docker_development
- SECRET_KEY_BASE=docker_development_secret
sidekiq:
volumes:
- ./logs/sidekiq/scraper:/usr/src/artifacts_scraper/log
image: davidgeismar/artifacts-scraper:without-db
command: 'bundle exec sidekiq -r ./artifacts_scraper.rb 2>&1 | tee ./log/sidekiq.log'
environment:
- REDIS_URL=redis://redis-server:6379/0
- ARTIFACTS_ENV=docker_development
- DATA_API_BASE=http://data_api:3000
depends_on:
- redis-server
- data_api
I execute it with docker-compose pull && docker-compose up --build
However data_api keeps on exiting telling me :
data_api_1 | A server is already running. Check /artifacts_data_api/tmp/pids/server.pid.
event though in my dockerfile for that service I have :
RUN rm -f ./tmp/pids/server.pid
On top of that I get SocketError: Failed to open TCP connection to data_api:3000 (getaddrinfo: Name or service not known) for the scraper service which Im unable to understand why it happens.
All containers are accessible and pullable from dockerhub.
The code for the scraper service :
https://github.com/davidgeismar/artifacts-scraper/tree/removing-db
and for the data_api:
https://github.com/davidgeismar/artifacts_data_api
I'm following this guide:
https://docs.docker.com/compose/rails/
I have all set up and running, and I'm trying to figure out how to connect with one of my DB client (Sequel Pro or pgAdmin) to the postgres container.
I also tried to map the postgres port in order to have it served outside from the container (docker-compose.yml), without success:
version: '3'
services:
db:
image: postgres
##### Trying this...
ports:
- "5432:5432"
#####
web:
build: .
command: bundle exec rails s -p 3030 -b '0.0.0.0'
volumes:
- .:/myapp
ports:
- "3030:3030"
depends_on:
- db
i have an Ruby on Rails project, which i want to place into the containers( there are database, redis and web(includes rails project) containers). I want to add search feature, so i added a sphinx container in my compose file
docker-compose.yml
web:
dockerfile: Dockerfile-rails
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
ports:
- "3000:3000"
links:
- redis
- db
**- sphinx**
environment:
- REDISTOGO_URL=redis://user#redis:6379/
redis:
image: redis
**sphinx:
image: centurylink/sphinx**
db:
dockerfile: Dockerfile-db
build: .
env_file: .env_db
docker-compose build works fine but when i run docke-compose up i get
ERROR: Cannot start container 096410dafc86666dcf1ffd5f60ecc858760fb7a2b8f2352750f615957072d961: Cannot link to a non running container: /metartaf_sphinx_1 AS /metartaf_web_1/sphinx_1
How can i fix this ?
According to https://hub.docker.com/r/centurylink/sphinx/ the Sphinx container runs needs some amount of configuration files to run properly. See the *Daemonized usage (2). You need data source files and a configuration.
In my test, it fails to start as is with error:
FATAL: no readable config file (looked in /usr/local/etc/sphinx.conf, ./sphinx.conf)
Your docker-compose.yml shouldn't have these * in it.
If you want sphinx latest version you can do this:
web:
dockerfile: Dockerfile-rails
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
ports:
- "3000:3000"
links:
- redis
- db
- sphinx
environment:
- REDISTOGO_URL=redis://user#redis:6379/
redis:
image: redis
sphinx:
image: centurylink/sphinx:latest
db:
dockerfile: Dockerfile-db
build: .
env_file: .env_db
If you want a specific version you write this way : centurylink/sphinx:2.1.8