Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I start one service in docker-compose without checking for or starting any dependencies?

We are using docker-compose in our dev environment to start all the services.

Does any one know if I can start just 1 service using docker-compose without checking if dependencies are running or not (since I know they are running)?

$ docker-compose -f docker-compose-service1.yml  up

it gives an error: ERROR: Service ‘service1’ depends on service ‘service2’ which is undefined.

The yml file looks something like:

version: '2'
services:

  service1:
    build: ./service1
    dns: 192.168.1.100
    depends_on:
      - "service2"
    container_name: service1

I just want to start service1 since I know all the dependencies are already running.

like image 290
user674669 Avatar asked Aug 02 '17 03:08

user674669


People also ask

How do I run a specific service in Docker compose?

To start (up), stop, restart or build a single service (container) using the Docker Compose, simply specify the name of the service against which to run the corresponding docker-compose command.

How can we control the start up order of services in Docker compose?

You can control the order of service startup and shutdown with the depends_on option. Compose always starts and stops containers in dependency order, where dependencies are determined by depends_on , links , volumes_from , and network_mode: "service:..." .

How do I run a docker compose detached?

Run Docker Compose in detached mode by passing the -d flag to docker-compose up . Use docker-compose ps to review what you have running.


1 Answers

If other services are running and you want to restart only one, you can use

docker-compose -f docker-compose.yml restart service1

Edit:

Regarding error:

ERROR: Service ‘service1’ depends on service ‘service2’ which is undefined.

It is because the docker-compose.yml which is used to up the services is not acceptable to docker-compose. First the yml file is compiled (the point of failure in our case) to see if everything is as per proper syntax, and then it is executed.

like image 101
Ayushya Avatar answered Oct 01 '22 07:10

Ayushya