I tried to build Docker container with Ruby on Rails application and can't do this.
Dockerfile
FROM ruby:2.5.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /noteapp
WORKDIR /noteapp
ADD Gemfile /noteapp/Gemfile
ADD Gemfile.lock /noteapp/Gemfile.lock
RUN bundle install
ADD . /noteapp
CMD ["rails","server","-b","0.0.0.0"]
docker-compose.yml
version: '2'
services:
db:
image: postgres
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/noteapp
ports:
- "3000:3000"
depends_on:
- db
After running command
sudo docker-compose up --build
I got the result, noteapp_web_1 exited with code 0 After this action I tried to up my docker container and everything was okey, but my application not responding on localhost:3000
When i tried to saw logs(sudo docker logs id), i got the result console_result
But when I tried to connect to my container, I can't do this, and got a error:
sudo docker attach ee43805fd6cf
You cannot attach to a stopped container, start it first
What should i do to run my application?
Update, i used the solution of @Upendra Chahar And got this problem rails_error
After that I fixed this problem and now i'm having problem with postgresql db: postgresql_db