In this article, we will illustrate how to do not start the entrypoint command on the “docker-compose up” command.
How to Don’t Start Entrypoint on “docker-compose up”?
There is no special option in the “docker-compose up” command to ignore the entrypoint of service. However, you can ignore the service by scaling it to zero while executing the “docker-compose up” command. For the demonstration, go through the listed instructions.
Step 1: Create “docker-compose.yml” File
First, create the compose file named “docker-compose.yml” file that contains configurations of multi containers applications. We have utilized the following configurations for the demonstration:
- “service” defines the application services that will execute in separate containers. For instance, we have configured the services “web” and “web1”.
- “build” key is used to specify the Dockerfile for the service. Here, for the first service, we have used “main.dockerfile” and the “web1” service will use “main1.dockerfile”.
- “commands” specify the entrypoint or executables for service. You can also specify the entrypoint in Dockerfile.
- “ports” allocates the exposing ports for the container on the local host:
services:
web:
build:
dockerfile: main.dockerfile
command: ["./webserver"]
ports:
- 8080
web1:
build:
dockerfile: main1.dockerfile
ports:
- 8080:8080
Step 2: Run Docker Compose Command
Next, fire up the containers through “docker-compose up”. This command will execute the compose file services in separate containers. Here, the “-d” option executes the configured services as a backend process:
Step 3: List the Containers
For the verification, list down the compose container using the mentioned command:
From the output, you can see “web” and “web1” services are executing in two different containers:
You can navigate to their exposing ports of containers to see the output and confirm if the containers are executing or not:
Step 4: Ignore Service While Using “docker-compose up”
To ignore the entrypoint of any service, simply scale the service to zero. For this purpose, utilize the “–scale” option along with the “<service>=0” value as shown below:
Again, list down the compose containers and verify if the specified service is ignored or not:
It can be observed that we have successfully ignored the entrypoint of the “web” service and only one “web1” service is executing in a container:
This is all about how to ignore the entrypoint command on the “docker-compose up” command.
Conclusion
To do not start the entrypoint of any service on the “docker-compose up” command, simply scale the service to zero. For this purpose, utilize the “docker-compose up” command along with the “–scale <service-name>=0” option. This write-up has illustrated how to not start the entrypoint command on the “docker-compose up” command.