Answers: <p>You can scale service that you don't want to run to 0</p>
  <p><code>docker-compose up --scale phpunit=0 -d</code> And it will not start container for phpunit service as stated in <a href="https://docs.docker.com/compose/reference/up/" rel="nofollow noreferrer">docs</a></p>
  <p>You can also check <a href="https://docs.docker.com/compose/profiles/" rel="nofollow noreferrer">compose profiles</a> for more options on excluding certain services in your docker-compose file.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-06-13T10:58:08.397Z
Answers: 2022-06-13T10:58:08.397Z
Answers: Darko Petrovic
Body: <p>I have multiple Docker containers in a project and I use <code>docker-compose up -d</code> to start containers.</p>
  <p>This is my <code>docker-compose.yml</code> file:</p>
  <pre class="lang-yml prettyprint-override"><code>version: &quot;3&quot;
  services:
    httpd:
      image: 'nginx:stable-alpine'
      ports:
        - '80:80'
      volumes:
        - ./laravel:/var/www/html
        - ./.docker-config/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      depends_on:
        - php
        - mysql
      networks:
        - backstage
  
    php:
      build:
        context: ./.docker-config/dockerfiles
        dockerfile: php.dockerfile
      volumes:
        - ./laravel:/var/www/html:delegated
      networks:
        - backstage
  
    mysql:
      image: mysql:5.7
      env_file:
        - ./.docker-config/mysql/mysql.env
      ports:
        - '33060:3306'
      networks:
        - backstage
  
    composer:
      build:
        context: ./.docker-config/dockerfiles
        dockerfile: composer.dockerfile
      volumes:
        - ./laravel:/var/www/html
      networks:
        - backstage
  
    artisan:
      build:
        context: ./.docker-config/dockerfiles
        dockerfile: php.dockerfile
      volumes:
        - ./laravel:/var/www/html
      entrypoint: [&quot;php&quot;, &quot;/var/www/html/artisan&quot;]
      depends_on:
        - mysql
      networks:
        - backstage
  
    npm:
      image: node:14-alpine
      working_dir: /var/www/html
      entrypoint: [&quot;npm&quot;]
      volumes:
        - ./laravel:/var/www/html
      networks:
        - backstage
  
    phpunit:
      build:
        context: ./.docker-config/dockerfiles
        dockerfile: php.dockerfile
      volumes:
        - ./laravel:/var/www/html
      entrypoint: [&quot;vendor/bin/phpunit&quot;]
      networks:
        - backstage
  </code></pre>
  <p>As you see, I defined <code>entrypoint</code> for the <code>phpunit</code> container, but I don't want to start the phpunit when I run <code>docker-compose up -d</code>.</p>
  <p>How can I do that?</p>
  
Comments: CC BY-SA 4.0
Comments: 2022-06-13T15:29:36.470Z
Comments: If you only want to start one specific service you can do `docker-compose up <servicename>`
Comments: Cowboy_Patrick
Tags: <docker><docker-compose>
Title: How to don't start entrypoint command on "docker-compose up"?
UserDisplayName: Ferenc Bablena
ThreadText: # How to don't start entrypoint command on "docker-compose up"?
  
  (Asked by: username_0 on 2022-06-13)
  
  I have multiple Docker containers in a project and I use `docker-compose up -d` to start containers.
  
  This is my `docker-compose.yml` file:
  
  ```yml
  version: "3"
  services:
    httpd:
      image: 'nginx:stable-alpine'
      ports:
        - '80:80'
      volumes:
        - ./laravel:/var/www/html
        - ./.docker-config/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      depends_on:
        - php
        - mysql
      networks:
        - backstage
  
    php:
      build:
        context: ./.docker-config/dockerfiles
        dockerfile: php.dockerfile
      volumes:
        - ./laravel:/var/www/html:delegated
      networks:
        - backstage
  
    mysql:
      image: mysql:5.7
      env_file:
        - ./.docker-config/mysql/mysql.env
      ports:
        - '33060:3306'
      networks:
        - backstage
  
    composer:
      build:
        context: ./.docker-config/dockerfiles
        dockerfile: composer.dockerfile
      volumes:
        - ./laravel:/var/www/html
      networks:
        - backstage
  
    artisan:
      build:
        context: ./.docker-config/dockerfiles
        dockerfile: php.dockerfile
      volumes:
        - ./laravel:/var/www/html
      entrypoint: ["php", "/var/www/html/artisan"]
      depends_on:
        - mysql
      networks:
        - backstage
  
    npm:
      image: node:14-alpine
      working_dir: /var/www/html
      entrypoint: ["npm"]
      volumes:
        - ./laravel:/var/www/html
      networks:
        - backstage
  
    phpunit:
      build:
        context: ./.docker-config/dockerfiles
        dockerfile: php.dockerfile
      volumes:
        - ./laravel:/var/www/html
      entrypoint: ["vendor/bin/phpunit"]
      networks:
        - backstage
  
  ```
  
  As you see, I defined `entrypoint` for the `phpunit` container, but I don't want to start the phpunit when I run `docker-compose up -d`.
  
  How can I do that?
  
  **Tags:** docker, docker-compose
  
  > **Comments:**
  > **username_1**: If you only want to start one specific service you can do `docker-compose up <servicename>`  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-06-13. Score: 2
  
  You can scale service that you don't want to run to 0
  
  `docker-compose up --scale phpunit=0 -d` And it will not start container for phpunit service as stated in [docs](https://docs.docker.com/compose/reference/up/)
  
  You can also check [compose profiles](https://docs.docker.com/compose/profiles/) for more options on excluding certain services in your docker-compose file.
  
  
  ---
  
  