snippetdockerMinor
How to don't start entrypoint command on "docker-compose up"?
Viewed 0 times
howdockerentrypointcomposestartcommanddon
Problem
I have multiple Docker containers in a project and I use
This is my
As you see, I defined
How can I do that?
docker-compose up -d to start containers.This is my
docker-compose.yml file: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?
Solution
You can scale service that you don't want to run to 0
You can also check compose profiles for more options on excluding certain services in your docker-compose file.
docker-compose up --scale phpunit=0 -d And it will not start container for phpunit service as stated in docsYou can also check compose profiles for more options on excluding certain services in your docker-compose file.
Context
StackExchange DevOps Q#16128, answer score: 2
Revisions (0)
No revisions yet.