Make a tools section

This commit is contained in:
Will Sargent 2014-11-13 15:24:33 +01:00
parent 976085430c
commit 5a84dfbefc

102
README.md
View file

@ -16,6 +16,7 @@ NOTE: This used to be a gist that continually expanded. It's now a github proje
* [Exposing Ports](https://github.com/wsargent/docker-cheat-sheet#exposing-ports)
* [Best Practices](https://github.com/wsargent/docker-cheat-sheet#best-practices)
* [Tips](https://github.com/wsargent/docker-cheat-sheet#tips)
* [Tools](https://github.com/wsargent/docker-cheat-sheet#tools)
## Why
@ -31,48 +32,7 @@ Docker helps developers build and ship higher-quality applications, faster." --
* [Building a Development Environment With Docker](http://tersesystems.com/2013/11/20/building-a-development-environment-with-docker/)
* [Discourse in a Docker Container](http://samsaffron.com/archive/2013/11/07/discourse-in-a-docker-container)
You may also like to try the following tools (and add more details here after you try them):
* [Fig](http://www.fig.sh/) is a helper app that makes it easier to run multiple docker containers on the same host. I would expect it to be used during dev/qa more than in production.
You can find instructions on how to install it at the above link.
Fig works with a ```fig.yml``` file (default name, use ```-f``` to provide a different filename) that defines the containers you wish to use with it. Fig will take it's project name from the name of the folder containing your yml configuration but you can override that with the ```-p``` parameter.
Once I have my config defined, I can use ```fig up -d``` to run it (the ```-d``` runs it as a background task). This will build (if required) start and link any containers.
You can do everything you do with fig using docker directly but running multiple containers with parameters would require some sort of script if you plan to do it more than once so the yml config of fig and the convenience commands it provides are worth considering.
Here's an example of setting up a ```fig.yml``` for an app with a apache packaged client container and a tomcat packaged app war:
First, here are the two docker commands to run these containers:
```
docker run -p 8080:8080 -v /Users/me/tomcatwork/trial.properties:/usr/share/tomcat6/trial.properties:rw -d me/tcfull
docker run -p 80:80 -v /Users/me/dockerwork/localproxy.conf:/etc/apache2/conf-enabled/proxy.conf:rw -d me/afull
```
at this point, I haven't linked the containers - I'm using the proxy.conf to specify the tomcat address.
my fig.yml looks like this:
```
app:
image: me/tcfull
ports:
- "8080"
volumes:
- /Users/me/tomcatwork/trial.properties:/usr/share/tomcat6/trial.properties:rw
web:
image: me/afull
ports:
- "80:80"
volumes:
- /Users/me/figwork/proxy.conf:/etc/apache2/conf-enabled/proxy.conf:rw
links:
- app
```
As you can see it follows the docker commands with the addition of names for the containers and a links section for the web container, linking it to the app container.
As part of that linking process, docker will copy any environment variables defined in the app container over to the web container, define new environment variables for the address the app container is running at and also add an app entry in the etc/hosts file for the web container. I can modify my proxy conf to address ```http://app:8080``` and fig/docker will take care of the rest.
I can then use commands like ```fig stop``` and ```fig rm``` to stop all my containers and remove them.
NB - docker will [eventually](https://gist.github.com/aanand/9e7ac7185ffd64c1a91a) absorb figs functionality with docker groups and docker up but it looks like they're keeping the yml config so it should be pretty seamless when it happens.
###Troubleshooting
```fig run``` is a useful command for debugging issues. It allows me to startup a named container (and any it links to) and run a one off command.
This allows me to do things like ```fig run web env``` which will give me a list of all the environment variables that are available on the web container including the ones generated via the link to app.
I can also use ```fig run web bash``` to run my web container interactively the way it has been setup by fig with the link to app so I can debug any issues from the command line.
* [Panamax](http://panamax.io/) -- nice web UI, will let you set up and download multiple docker containers.
* [Vessel](http://awvessel.github.io/)
You may also like to try the [tools section](https://github.com/wsargent/docker-cheat-sheet#tools).
## Prerequisites
@ -434,3 +394,61 @@ docker rmi $(docker images -q)
```
docker images -viz | dot -Tpng -o docker.png
```
## Tools
### Fig
[Fig](http://www.fig.sh/) is a helper app that makes it easier to run multiple docker containers on the same host. I would expect it to be used during dev/qa more than in production.
Fig works with a ```fig.yml``` file (default name, use ```-f``` to provide a different filename) that defines the containers you wish to use with it. Fig will take its project name from the name of the folder containing your yml configuration but you can override that with the ```-p``` parameter.
Once I have my config defined, I can use ```fig up -d``` to run it (the ```-d``` runs it as a background task). This will build (if required) start and link any containers.
You can do everything you do with fig using docker directly but running multiple containers with parameters would require some sort of script if you plan to do it more than once so the yml config of fig and the convenience commands it provides are worth considering.
Here's an example of setting up a ```fig.yml``` for an app with a apache packaged client container and a tomcat packaged app war:
First, here are the two docker commands to run these containers:
```
docker run -p 8080:8080 -v /Users/me/tomcatwork/trial.properties:/usr/share/tomcat6/trial.properties:rw -d me/tcfull
docker run -p 80:80 -v /Users/me/dockerwork/localproxy.conf:/etc/apache2/conf-enabled/proxy.conf:rw -d me/afull
```
at this point, I haven't linked the containers - I'm using the proxy.conf to specify the tomcat address.
my fig.yml looks like this:
```
app:
image: me/tcfull
ports:
- "8080"
volumes:
- /Users/me/tomcatwork/trial.properties:/usr/share/tomcat6/trial.properties:rw
web:
image: me/afull
ports:
- "80:80"
volumes:
- /Users/me/figwork/proxy.conf:/etc/apache2/conf-enabled/proxy.conf:rw
links:
- app
```
As you can see it follows the docker commands with the addition of names for the containers and a links section for the web container, linking it to the app container.
As part of that linking process, docker will copy any environment variables defined in the app container over to the web container, define new environment variables for the address the app container is running at and also add an app entry in the etc/hosts file for the web container. I can modify my proxy conf to address ```http://app:8080``` and fig/docker will take care of the rest.
I can then use commands like ```fig stop``` and ```fig rm``` to stop all my containers and remove them.
NB - docker will [eventually](https://gist.github.com/aanand/9e7ac7185ffd64c1a91a) absorb figs functionality with docker groups and docker up but it looks like they're keeping the yml config so it should be pretty seamless when it happens.
###Troubleshooting
```fig run``` is a useful command for debugging issues. It allows me to startup a named container (and any it links to) and run a one off command.
This allows me to do things like ```fig run web env``` which will give me a list of all the environment variables that are available on the web container including the ones generated via the link to app.
I can also use ```fig run web bash``` to run my web container interactively the way it has been setup by fig with the link to app so I can debug any issues from the command line.
### Panamax
[Panamax](http://panamax.io/) -- nice web UI, will let you set up and download multiple docker containers.
### Vessel
* [Vessel](http://awvessel.github.io/)