Intro to Docker on Windows

#72 Intro to Docker on Windows
3/19/2017

Summary

Developing a Ruby on Rails application on Windows can be difficult, but doesn't have to be with Docker. Learn how to use Docker to create isolated containers and get them to talk with the Rails app and passed through to the local computer.
1
rails development deployment 11:19 min

Summary

Terminaldocker build . -t railsapp
docker-compose up
docker-compose start web
docker-compose stop web
DockerfileFROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs 
RUN apt-get install libmysqlclient-dev -y
RUN apt-get install sqlite3 -y
RUN apt-get install coffeescript gawk g++ gcc make libreadline6-dev -y
RUN apt-get install libssl-dev libyaml-dev libsqlite3-dev autoconf libgmp-dev libgdbm-dev -y
RUN apt-get install libncurses5-dev automake libtool bison pkg-config libffi-dev -y
RUN mkdir /railsapp
RUN echo 'gem: --no-document' >> ~/.gemrc
EXPOSE 3000
WORKDIR /railsapp
ADD Gemfile /railsapp/Gemfile
ADD Gemfile.lock /railsapp/Gemfile.lock
RUN bundle install
ADD . /railsapp
docker-compose.ymlversion: '2'

services:
  web:
    build: .
    command: bash -c "bundle && bundle exec rake db:create db:migrate db:seed && bundle exec rails s -b 0.0.0.0"
    volumes:
      - .:/railsapp
    ports:
      - 3000:3000
    depends_on:
      - redis
      - mysql
  redis:
    image: redis
    ports:
      - 6379:6379
  mysql:
    image: mysql:5.7
    command: mysqld --character-set-server=utf8
    ports:
      - 3306:3306
    restart: always
    volumes: 
      - ../docker/mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: development
      MYSQL_DATABASE: template_development
      MYSQL_USER: dbuser
      MYSQL_PASSWORD: password
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - 8080:80
    depends_on:
      - mysql
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      PMA_USER: dbuser
      PMA_PASSWORD: password
60613?v=3&s=64
chabgood said 3 months ago:

I am getting this error:

#<Mysql2::Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)>

Login to Comment