I am learning Docker and trying to run container on Win11, which is running successfully, but it doesn't connect to localhost.
This is my Dockerfile
FROM ruby:3.1.2
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
WORKDIR /test
COPY Gemfile /test/Gemfile
COPY Gemfile.lock /test/Gemfile.lock
RUN bundle install
EXPOSE 3000
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
And docker-compose.yml
services:
db:
image: postgres:14.8
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: 12345
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/test
ports:
- "3000:3000"
depends_on:
- db
After I run docker compose up
console shows that Server is running.
But when I open the localhost there is an error.