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 clean saved dockerfiles after build
  • My docker data-only container is empty
  • Angular 2 Webpack Docker Error On development
  • Docker / how to determine link?
  • Kubernetes on CoreOS: Proxy service max out CPU
  • Adding sphinx container docker-compose shows an error
  • 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

  • Docker container connect to MySQL database locally -> redirect to another container
  • Docker image is not visible when I run docker ps
  • how to access environment variables in Windows Docker healthcheck script
  • Docker - cannot connect to the Docker daemon
  • Wordpress on docker-compose no run
  • Cron job can't connect to Docker daemon
  • 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.