Docker

How to Don’t Start Entrypoint Command on “docker-compose up”

Docker compose is a Docker CLI tool utilized to manage and configure multi-container applications and services. The Docker compose executes the web application services individually in separate containers. Sometimes, developers do not want to execute all services of the application and ignore the entry point of the service to ignore it. There is no specific option in Docker compose to ignore the entrypoint. However, you can ignore the specific service while running the “docker-compose up” command by scaling the service to zero.

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:
version: "alpine"
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:

docker-compose up -d

Step 3: List the Containers
For the verification, list down the compose container using the mentioned command:

docker-compose ps -a

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:

docker-compose up -d --scale web=0

Again, list down the compose containers and verify if the specified service is ignored or not:

docker-compose ps -a

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.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.