2

I've created the docker-compose.yml file below to create a container based on Ruby image and a container based on MySQL image. When I execute docker-compose up, the MySQL container seems to be created correctly, however it is not run in the background. How can I configure it to do so using the docker-compose.yml file?

version: '2'

services:
  web:
    build: 
      context: .
      dockerfile: .docker/rails.dockerfile
    volumes: 
      - .:/var/www
    ports: 
      - "3000:3000"
    depends_on:
      - 'mysql'
    networks:
      - ddoc-network


  mysql:
    image: mysql
    environment: 
      MYSQL_ROOT_PASSWORD: 'SOMETHING'
    networks:
      - ddoc-network


networks:
  ddoc-network:
    driver: bridge

rails.dockerfile

FROM ruby:2.3.1

MAINTAINER Juliano Nunes

RUN apt-get update -qq && apt-get install -y build-essential mysql-client libmysqlclient-dev nodejs
RUN mkdir /var/www
WORKDIR /var/www

ADD Gemfile /var/www/Gemfile
ADD Gemfile.lock /var/www/Gemfile.lock
RUN bundle install
ADD . /var/www

CMD ['bundle', 'exec', 'rails', 'server', '-b', '0.0.0.0']

CMD

1 Answer 1

1

You can always use docker-compose up -d to run your containers in detached mode.

Check docker-compose up --help for more info.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.