Can you define additional services for sockets?

Is there a way to define a Docker Compose service in such a way that it only brings up when you explicitly request it?

I.e:

 docker-compose up 

doesn't start it but

 docker-compose up optional_service 

will be.

+12
source share
1 answer

One way to achieve this is to define your additional service in another file. Then, to start the additional service, run:

 $ docker-compose -f docker-compose.yml -f optional-service.yaml up 

For example, if I have a docker-compose.yml file that looks like this:

 version: '2.1' services: lb: image: nginx:1.13 db: image: redis:3.2.9 

I can expand it with option-service.yml, which looks like this:

 version: '2.1' services: busy: image: busybox 

Note that both compound files must use the same version of the compound file.

You can read more about this in the Compose documentation .

+18
source

Source: https://habr.com/ru/post/1270867/


All Articles