How to make MySQL container run in the background when configured in docker-compose

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

  • How to stop docker pull
  • defining resource limitation and using volumes in dockerfile?
  • Set up mapping in Elasticsearch during Docker run
  • How to get tomcat log from docker container running in atomic host
  • SBT Docker ADD file not found
  • Docker error when uploading image
  • 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

  • How to send the parameters to command in docker with --entrypoint
  • Not able to replace NGINX with NGINX Plus as reverse proxy for microservices on Google Cloud using Kubernetes
  • Docker-machine create: Error with pre-create check: “Hyper-v commands have to be run as an Administrator”
  • how to package a docker image in a single file
  • Using nginx as a proxy to to java web servlet
  • How do I run a node container on AWS ECS without exiting
  • One Solution collect form web for “How to make MySQL container run in the background when configured in docker-compose”

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

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

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.