we're using docker containers for both development and deplyoment since a while now and it works like a charm. Up untill now both the configuration were identical, and with fig on top the developer's life is way easier as well.
As we use it more and more in our node-development cicle now we face the need to have some extra tools while developing (inspector, profiles, etc), stuff that clearly is not needed in a production container. Once more catch with node-inspector is: it needs to expose a port to connect to with a browser in order to see the tool its self.
here's brieffly our fig.yml file:
indexer:
build: .
volumes:
- .:/src
links:
- db
- amqp
- search
amqp:
ports:
- "5672:5672"
- "15672:15672"
image: mikaelhg/docker-rabbitmq
db:
ports:
- "3306:3306"
image: tutum/mysql:5.6
search:
ports:
- "9002:9002"
- "9300:9300"
image: dockerfile/elasticsearch
"Indexer" is our app container and it can be lauched more than once, changeing it's configuration to:
indexer:
ports:
- "8080:8080"
build: .
volumes:
- .:/src
links:
- db
- amqp
- search
burries a littel problem: as we launch many of them the mapped ports clearly become a problem and no inspector is actually avvailable.
My 1st getto solution was just to cread a new "indexer-dev" container to launch just for debugging purposes, but it falls short as we run a convenient fig up
on a shell just to bring everything up, and then another fig run indexer dev bash
in another one for our debugging purposes.
So what I'm doing now it's just a fig up
followed by manually launching the container with the neede forwarded ports:
docker run -i -t -p 8080:8080 indexer:latest
What would it be the best way to have this in a more automatic way? Such as developers can convently keep launching containers throught fig and choosing wich instance might or might not have exported ports?
Thank you for any suggestion.
cheers lucio
you can pass in environment variable when calling fig up
or fig run
take the following fig config file:
test:
image: base
command: env
environment:
- DEBUG
which defines a container named test
that will print out the environment variables. Note that in the environment
section we define a environment variable DEBUG
without value.
When run with fig up
or fig run
it will have the DEBUG
environment variable defined with no value
$ fig run test
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=5412e54ea3de
TERM=xterm
DEBUG=
HOME=/root
but you can inject a new value for the DEBUG
environment variable as follow:
$ DEBUG=true fig run test
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=9150d89c57a2
TERM=xterm
DEBUG=true
HOME=/root
This allows you to pass in secrets or have your container behave differently depending on some environment variables.
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