How to configure docker compose with equivalent for -d (detach)

1

The following command runs a container with mysql in the background.

docker run -d -p 3306:3306 -e MYSQL_RANDOM_ROOT_PASSWORD=yes --name mysqldb mysql

The equivalent with docker-compose.yml would be:

version: '2'

services:
  mysqldb:
    image: mysql
    ports:
      - 3306:3306
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: yes

But when I run using docker-compose up the process stays in the foreground. How do I add the equivalent of the detach option ( -d ) of docker container run ?

    
asked by anonymous 21.12.2017 / 21:18

1 answer

2

You can use the command: docker-compose up -d . This command starts the containers in the background and leaves them running. Learn more in the Docker documentation link .

    
22.12.2017 / 01:22