{ "info": { "author": "Florent PIGOUT", "author_email": "florent.pigout@people-doc.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2.7" ], "description": "Bag8\r\n====\r\n\r\n.. image:: https://travis-ci.org/novafloss/bag8.svg\r\n :target: https://travis-ci.org/novafloss/bag8\r\n :alt: We are under CI!!\r\n\r\nLet's explain how to orchestrate docker images and containers the easy way.\r\n\r\nInstallation\r\n------------\r\n\r\n.. code:: console\r\n\r\n @me ~$ pip install bag8\r\n\r\nThe config file\r\n---------------\r\n\r\nBag8 read his config from `~/.config`. You can override some values by adding\r\na `bag8.yml` file there:\r\n\r\n.. code:: yaml\r\n\r\n account: \r\n registry: \r\n data_paths:\r\n - \r\n\r\nThe data tree\r\n-------------\r\n\r\nIn ``bag8`` project we illustrate a simple project tree:\r\n\r\n.. code:: console\r\n\r\n @me ~$ tree data/\r\n data/\r\n \u251c\u2500\u2500 busybox\r\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 Dockerfile\r\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 fig.yml\r\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 site.conf\r\n \u251c\u2500\u2500 link\r\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 Dockerfile\r\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 fig.yml\r\n \u2514\u2500\u2500 link.2\r\n \u251c\u2500\u2500 Dockerfile\r\n \u2514\u2500\u2500 fig.yml\r\n\r\n.. note:: Each project should contain a Dockerfile for the build actions, and\r\n a fig.yml file for the orchestration.\r\n\r\n.. note:: We use the name of the folders as project names.\r\n\r\nThe CLI\r\n-------\r\n\r\n``Bag8`` commands can be run from anywhere since the ``bag8`` executable is\r\navailable in your current path and your config include your project ``data``\r\ndir in the ``data_paths`` list.\r\n\r\nThanks to ``click`` cli framework, ``bag8`` command and subcommands will all\r\nprint there documentation with the ``--help`` argument.\r\n\r\nMy first build\r\n--------------\r\n\r\nHere is how we rebuild a ``bag8`` image. You can build it from anywhere since\r\nthe ``bag8`` command is available in your current path and your ``bag8.yml``\r\nconfig include the ``bag8`` project ``data`` dir in the ``data_paths`` list.\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 build busybox\r\n @me ~$ docker images\r\n REPOSITORY TAG IMAGE ID\r\n bag8/busybox latest 59e5138d13f3\r\n\r\nHere is how we can push it to the *bag8* account of the *docker HUB*:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 push busybox\r\n\r\nYou can change ``account`` and ``registry`` value in your config according your\r\nneeds, for example:\r\n\r\n.. code:: yaml\r\n\r\n account: rd\r\n registry: hub.mylittlecompany.org\r\n\r\nIt should build an tag your images as follow to be pushed to your registry:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 build busybox\r\n @me ~$ docker images\r\n REPOSITORY TAG IMAGE ID\r\n hub.mylittlecompany.org/rd/busybox latest 59e5138d13f3\r\n\r\nLet's up\r\n--------\r\n\r\nIn our demo data we have a ``busybox`` project to link with a ``link`` project.\r\n``busybox`` container should wait and ``link`` container listen for some calls\r\non the 1234 port.\r\n\r\nUp\r\n^^\r\n\r\nBy default if you up the ``busybox`` project it will start a ``link`` container\r\nas ``busybox`` dependency then a ``busybox`` container. When the ``busybox``\r\ncontainer starts, and because ``link`` container expose port 1234, it will\r\nwait that ``link`` container is ready and really listen on 1234.\r\n\r\n.. note:: To test port availability we need correct dns setup. See bellow for\r\n more info about it.\r\n\r\nHere is want we should have:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 dns # to make sure dnsdock is up\r\n @me ~$ bag8 up busybox\r\n Creating busybox_link_1...\r\n Creating busybox_busybox_1...\r\n wait for link.docker:1234\r\n\r\nThen both containers should respond with the name of the container ., ex.:\r\n\r\n.. code:: console\r\n\r\n @me ~$ ping link.docker -c 1\r\n PING link.docker (172.17.42.10) 56(84) bytes of data.\r\n 64 bytes from 172.17.42.10: icmp_seq=1 ttl=64 time=0.075 ms\r\n ...\r\n\r\nStop\r\n^^^^\r\n\r\nYou can remove or stop all the ``busybox`` project containers as follow:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 rm busybox # or stop instead of rm\r\n Stopping busybox_busybox_1...\r\n Stopping busybox_link_1...\r\n Removing busybox_link_1...\r\n Removing busybox_busybox_1...\r\n\r\nTo remove, stop or start one container only of the ``busybox`` project, you\r\nneed to add the *-s* option to the bag8 corresponding command as follow:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 stop busybox -s link\r\n Stopping busybox_link_1...\r\n\r\nAbout projects\r\n--------------\r\n\r\nLet's say a project is a set of containers linked together to run a final app.\r\nFor example, the ``busybox`` project has two containers. The ``busybox`` up\r\nwhen the required ``link`` container is up.\r\n\r\nDefault prefix\r\n^^^^^^^^^^^^^^\r\n\r\nWe use the project name as prefix of the project container names, ex.:\r\n\r\n.. code:: console\r\n\r\n @me ~$ docker ps\r\n CONTAINER ID IMAGE ... NAMES\r\n 28e0a48b30ec bag8/busybox ... busybox_busybox_1\r\n fc7ff2358235 bag8/link ... busybox_link_1\r\n\r\nCustom prefix\r\n^^^^^^^^^^^^^\r\n\r\nWe can specify the prefix we want when we start a project, ex.:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 up link -p bag8\r\n Creating bag8_link_1...\r\n\r\nReuse containers\r\n^^^^^^^^^^^^^^^^\r\n\r\nIf containers with the same name are already running, ``bag8`` does not start\r\nnew ones. For example, if you re-run the command twice. It won't print nothing:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 up link -p bag8\r\n\r\nMixing projects\r\n^^^^^^^^^^^^^^^\r\n\r\nPrefixing and reusing containers allow us to start several projects and mix\r\nthem all together. For example if we start the ``busybox`` we the same prefix\r\nthan ``link``, it will just link to the existing one:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 up busybox -p bag8\r\n Creating bag8_busybox_1...\r\n\r\nEtc.\r\n\r\nWise up\r\n^^^^^^^\r\n\r\nIf you do not specify project name in your command, ``bag8`` will use your\r\ncurrent dir name as project name:\r\n\r\n.. code:: console\r\n\r\n @me ~$ mkdir busybox\r\n @me ~$ cd busybox\r\n @me ~/busybox$ bag8 up\r\n Creating busybox_busybox_1...\r\n ...\r\n\r\nDevelop\r\n-------\r\n\r\nAs we can see ``bag8`` is mostly oriented for development usage. Here we\r\nintroduce an additional feature named *develop*.\r\n\r\nLet's you are in your development folder and you want to work with your local\r\ncode in your ``bag8`` environment. You can run the following command:\r\n\r\n.. code:: console\r\n\r\n @me ~/busybox$ bag8 stop -s busybox # first we need to stop the previous container\r\n @me ~/busybox$ bag8 develop -c sh\r\n Creating busybox_busybox_1...\r\n / #\r\n\r\n.. note:: By default develop command use bash interpreter to enter in the\r\n development container. Busybox doesn't have bash, so we had *- c*\r\n argument for the demo.\r\n\r\nFor the demo we mounted the ``/tmp`` folder of the busybox to the current dir.\r\nIt could have been your project sources. In practice, changes in the container\r\npersist locally.\r\n\r\n.. code:: console\r\n\r\n / # touch /tmp/this-is-a-demo\r\n / # exit\r\n @me ~/busybox$ ls\r\n this-is-a-demo\r\n\r\nNginx\r\n-----\r\n\r\nAs developer tool, ``bag8`` helps in serving your services with nginx. Let's\r\nsay the busybox container is linked to a link container that listen on 1234.\r\n\r\n.. code:: console\r\n\r\n @me ~/busybox$ bag up\r\n @me ~/busybox$ curl -I link.docker:1234\r\n HTTP/1.1 200 OK\r\n\r\nYou can write an nginx config for the busybox project that will proxy the link\r\nservice. Then by running the ``bag8 nginx`` command, the tool will copy the\r\nconfig in a common folder and share it in the nginx container to start:\r\n\r\n.. code:: console\r\n\r\n @me ~/busybox$ bag nginx\r\n @me ~/busybox$ curl -I busybox.nginx.docker\r\n HTTP/1.1 200 OK\r\n Server: nginx/1.9.11\r\n Date: Wed, 08 Jun 2016 21:32:10 GMT\r\n Connection: keep-alive\r\n\r\nDns\r\n---\r\n\r\nBag8 uses `dnsdock` (cf.: https://github.com/tonistiigi/dnsdock) to help in\r\ncontainer `ip` resolution. Bag8 adds extra `DNSDOCK_ALIAS` environment variable\r\nto each container. It permits to resolve the container `ip` from the host or\r\nfrom another container.\r\n\r\nTo make it work, you need to setup your docker service and your network\r\nproperly.\r\n\r\nFirst we suggest the following dnsmasq conf:\r\n\r\n.. code:: console\r\n\r\n @me ~$ cat /etc/dnsmasq.d/50-docker\r\n bind-interfaces\r\n except-interface=docker0\r\n server=/docker/172.17.42.1\r\n\r\nAs suggested in the `dnsdock` page, you need the following `DOCKER_OPTS`:\r\n\r\n.. code::\r\n\r\n DOCKER_OPTS=\"-bip 172.17.42.1/24 -dns 172.17.42.1\"\r\n\r\nAt the end, to enable `dnsdock` and check you are resolving the busybox, you\r\ncan type the following commands:\r\n\r\n.. code:: console\r\n\r\n @me ~$ bag8 dns # it pulls the dnsdock and runs it\r\n @me ~$ dig busybox.docker\r\n ; <<>> DiG 9.9.5-9+deb8u3-Debian <<>> busybox\r\n ...\r\n ;; QUESTION SECTION:\r\n ;busybox.docker. IN A\r\n\r\n ;; ANSWER SECTION:\r\n busybox.docker. 0 IN A 172.17.42.204", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/novafloss/bag8", "keywords": "docker docker-compose bag8", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "bag8", "package_url": "https://pypi.org/project/bag8/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/bag8/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/novafloss/bag8" }, "release_url": "https://pypi.org/project/bag8/1.0/", "requires_dist": null, "requires_python": null, "summary": "Cli to orchestrate docker the easy way", "version": "1.0" }, "last_serial": 2160476, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "2bcd1fd5fdb7613d84deada604a7bfa8", "sha256": "ed2e18b55d5ff9eb49e020e814d6f8e8729bd74f0dc3e303e2b8da09eef32eb7" }, "downloads": -1, "filename": "bag8-1.0-py27-none-any.whl", "has_sig": false, "md5_digest": "2bcd1fd5fdb7613d84deada604a7bfa8", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 20478, "upload_time": "2016-06-10T10:02:24", "url": "https://files.pythonhosted.org/packages/5e/ae/e9ad7e5584560e2cfae4c93d3d58bee680ab7586d287dc6b639ac1bb4637/bag8-1.0-py27-none-any.whl" }, { "comment_text": "", "digests": { "md5": "46a8213043a9a0e149d3543cd79d6ab0", "sha256": "708e0d0e15370833a274f37eec67abd1db13f3e550580352a1da4e6743e838a8" }, "downloads": -1, "filename": "bag8-1.0.tar.gz", "has_sig": false, "md5_digest": "46a8213043a9a0e149d3543cd79d6ab0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19209, "upload_time": "2016-06-10T10:02:19", "url": "https://files.pythonhosted.org/packages/f1/c2/e6e2a481b8300eeb8df0012239aa17d5cacedf93dd8776da2af86921b299/bag8-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2bcd1fd5fdb7613d84deada604a7bfa8", "sha256": "ed2e18b55d5ff9eb49e020e814d6f8e8729bd74f0dc3e303e2b8da09eef32eb7" }, "downloads": -1, "filename": "bag8-1.0-py27-none-any.whl", "has_sig": false, "md5_digest": "2bcd1fd5fdb7613d84deada604a7bfa8", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 20478, "upload_time": "2016-06-10T10:02:24", "url": "https://files.pythonhosted.org/packages/5e/ae/e9ad7e5584560e2cfae4c93d3d58bee680ab7586d287dc6b639ac1bb4637/bag8-1.0-py27-none-any.whl" }, { "comment_text": "", "digests": { "md5": "46a8213043a9a0e149d3543cd79d6ab0", "sha256": "708e0d0e15370833a274f37eec67abd1db13f3e550580352a1da4e6743e838a8" }, "downloads": -1, "filename": "bag8-1.0.tar.gz", "has_sig": false, "md5_digest": "46a8213043a9a0e149d3543cd79d6ab0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19209, "upload_time": "2016-06-10T10:02:19", "url": "https://files.pythonhosted.org/packages/f1/c2/e6e2a481b8300eeb8df0012239aa17d5cacedf93dd8776da2af86921b299/bag8-1.0.tar.gz" } ] }