compose icon indicating copy to clipboard operation
compose copied to clipboard

Dependencies on startup

Open vgeyer opened this issue 12 years ago • 7 comments

Hi there, I've got a little problem. I did this:

web:
  build: ./env/web/
  volumes:
    - ./env/web/:/var/www/html
cli:
  build: ./env/cli/
  volumes:
    - ./env/cli/:/app/
db:
  image: dockerfile/mariadb
  volumes:
    - ./data/db/mysql/:/var/lib/mysql/

Well, a fig build works nice, a fig up_ produces something like that:

Recreating exampletv_web_1...
Recreating exampletv_db_1...
Recreating exampletv_cli_1...
Attaching to exampletv_web_1, exampletv_cli_1
web_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.178. Set the 'ServerName' directive globally to suppress this message
web_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.178. Set the 'ServerName' directive globally to suppress this message
web_1 | [Tue Nov 25 15:57:16.325314 2014] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/5.6.3 configured -- resuming normal operations
web_1 | [Tue Nov 25 15:57:16.325421 2014] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
exampletv_cli_1 exited with code 0
Gracefully stopping... (press Ctrl+C again to force)
Stopping exampletv_web_1..

I think because of the cli container which is a run once container and does nothing by default. This is the desired behavior because fig run cli /bin/bash should be run manually.

Is there any way to disable this "dependency" behavior?

vgeyer avatar Nov 25 '14 16:11 vgeyer

Possibly a silly question, but did you run fig up -d or fig up? Without -d, fig runs 'interactively', so pressing CTRL-C will the containers that were started by fig.

With -d, fig will start the containers in the background ('daemonized') and they will keep running.

thaJeztah avatar Nov 25 '14 16:11 thaJeztah

I tried both, but even with -d all containers exited silently..

vgeyer avatar Nov 25 '14 17:11 vgeyer

Yeah, I think the design of fig up is to start all services, and then stop them as soon as one of them ~~exists~~ exits. I'd guess that your cli service exits immediately because the services are run non-interactively (no stdin). I think the recommended way to do this would be to use fig up db web to start just those services.

That said, it would be nice if there were a way to exclude certain services from fig up.

nonsensery avatar Nov 27 '14 00:11 nonsensery

kk, thy!

This would be a nice feature! +1

vgeyer avatar Nov 27 '14 13:11 vgeyer

I tried both, but even with -d all containers exited silently..

-d should run them in the background, did you try fig ps or docker ps to see what was running?

dnephin avatar Dec 02 '14 04:12 dnephin

FYI: I've submitted a proposal (Issue #697) to allow certain containers, like your cli container, to be excluded when running fig up.

nonsensery avatar Dec 03 '14 01:12 nonsensery

As of docker-compose 1.4 up will keep running until all containers have stopped

dnephin avatar Sep 18 '15 20:09 dnephin