If we would prefer to have some of our containers execute in the background while still using fuge we can do this by tweaking our Fuge configuration file.
For demonstration purposes, we'll copy micro/fuge/fuge.yml to micro/fuge/fuge2.yml.
Let's micro/fuge/fuge2.yml and update the fuge_global section by adding the run_containers setting as follows:
fuge_global:
run_containers: false
tail: true
monitor: true
monitor_excludes:
- '**/node_modules/**'
- '**/.git/**'
- '*.log'
Now we'll start up the Fuge shell with the fuge/fuge2.yml configuration and run Fuge's ps command:
$ cd micro
$ fuge shell fuge/fuge2.yml
fuge> ps
name type status watch tail
adderservice process stopped yes yes
auditservice process stopped yes yes
webapp process stopped yes yes
mongo container not managed
Fuge reports that the mongo container is not managed.
In another terminal window we can run the mongo container using Docker directly:
$ docker run -p 127.0.0.1:27017:27017 -d mongo
This will start the MongoDB container in the background and expose port 27017 from the container to the localhost interface. We can now connect to this using the auditservice or through the standard Mongodb client. We can check this by running:
$ docker ps
We can start the rest of our system in the Fuge shell:
fuge> start all
Then we can confirm that everything is running as before by navigating our browser to and using the routes we've been creating in this and previous recipes.
If we exit the Fuge shell the mongo container will continue to run.
The key point to note here is that we can leave our infrastructure containers running in the background and tell Fuge about them. Fuge will then generate the appropriate environment variables (and other information) to allow us to access the container, but it will not attempt to start or stop the container.