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.
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.
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:..." .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With