Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 1 | |
| 2 | ====== |
| 3 | Docker |
| 4 | ====== |
| 5 | |
| 6 | Docker is a platform for developers and sysadmins to develop, ship, and run applications. Docker lets you quickly assemble applications from components and eliminates the friction that can come when shipping code. Docker lets you get your code tested and deployed into production as fast as possible. |
| 7 | |
| 8 | Docker is supported on the following systems: |
| 9 | |
| 10 | * Debian 8.0 Jessie (64-bit) |
| 11 | * Ubuntu Trusty 14.04 (LTS) (64-bit) |
| 12 | * Ubuntu Precise 12.04 (LTS) (64-bit) |
| 13 | * Ubuntu Raring 13.04 and Saucy 13.10 (64 bit) |
| 14 | |
| 15 | Sample pillar |
| 16 | ------------- |
| 17 | |
Filip Pytloun | e27a90d | 2016-08-29 14:08:34 +0200 | [diff] [blame] | 18 | Host |
| 19 | ---- |
| 20 | |
Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 21 | .. code-block:: yaml |
| 22 | |
| 23 | docker: |
| 24 | host: |
| 25 | enabled: true |
Filip Pytloun | 972294d | 2016-09-15 17:52:32 +0200 | [diff] [blame] | 26 | insecure_registries: |
| 27 | - 127.0.0.1 |
Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 28 | |
Filip Pytloun | 2720a0d | 2016-11-02 14:15:55 +0100 | [diff] [blame^] | 29 | Swarm |
| 30 | ----- |
| 31 | |
| 32 | Role can be master, manager or worker. Where master is the first manager that |
| 33 | will initialize the swarm. |
| 34 | |
| 35 | Metadata for manager (first node): |
| 36 | |
| 37 | .. code-block:: yaml |
| 38 | |
| 39 | docker: |
| 40 | host: |
| 41 | enabled: true |
| 42 | swarm: |
| 43 | role: manager |
| 44 | advertise_addr: 192.168.1.5 |
| 45 | bind: |
| 46 | address: 192.168.1.5 |
| 47 | port: 2377 |
| 48 | |
| 49 | Metadata for worker: |
| 50 | |
| 51 | .. code-block:: yaml |
| 52 | |
| 53 | docker: |
| 54 | host: |
| 55 | enabled: true |
| 56 | swarm: |
| 57 | role: worker |
| 58 | master: |
| 59 | host: 192.168.1.5 |
| 60 | port: 2377 |
| 61 | |
| 62 | Token to join to master node is obtained from grains using salt.mine. In case |
| 63 | of any ``join_token undefined`` issues, ensure you have ``docker_swarm_`` |
| 64 | grains available. |
| 65 | |
Filip Pytloun | e27a90d | 2016-08-29 14:08:34 +0200 | [diff] [blame] | 66 | Client |
| 67 | ------ |
Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 68 | |
Filip Pytloun | 96fc0cc | 2016-08-29 16:01:10 +0200 | [diff] [blame] | 69 | Container |
| 70 | ~~~~~~~~~ |
| 71 | |
| 72 | .. code-block:: yaml |
| 73 | |
Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 74 | docker: |
Filip Pytloun | e27a90d | 2016-08-29 14:08:34 +0200 | [diff] [blame] | 75 | client: |
Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 76 | container: |
Filip Pytloun | 8716954 | 2016-08-29 13:38:30 +0200 | [diff] [blame] | 77 | jenkins: |
| 78 | # Don't start automatically |
| 79 | start: false |
| 80 | restart: unless-stopped |
| 81 | image: jenkins:2.7.1 |
Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 82 | ports: |
Filip Pytloun | 8716954 | 2016-08-29 13:38:30 +0200 | [diff] [blame] | 83 | - 8081:8080 |
| 84 | - 50000:50000 |
| 85 | environment: |
| 86 | JAVA_OPTS: "-Dhudson.footerURL=https://www.example.com" |
| 87 | volumes: |
| 88 | - /srv/volumes/jenkins:/var/jenkins_home |
Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 89 | |
Filip Pytloun | 96fc0cc | 2016-08-29 16:01:10 +0200 | [diff] [blame] | 90 | Compose |
| 91 | ~~~~~~~ |
| 92 | |
Filip Pytloun | 21d9af9 | 2016-08-30 08:13:39 +0200 | [diff] [blame] | 93 | There are three options how to install docker-compose: |
| 94 | |
| 95 | - distribution package (default) |
| 96 | - using Pip |
| 97 | - using Docker container |
| 98 | |
| 99 | Install docker-compose using Docker (default is distribution package) |
Filip Pytloun | 96fc0cc | 2016-08-29 16:01:10 +0200 | [diff] [blame] | 100 | |
| 101 | .. code-block:: yaml |
| 102 | |
| 103 | docker: |
| 104 | client: |
| 105 | compose: |
Filip Pytloun | 21d9af9 | 2016-08-30 08:13:39 +0200 | [diff] [blame] | 106 | source: |
| 107 | engine: docker |
| 108 | image: docker/compose:1.8.0 |
Filip Pytloun | 96fc0cc | 2016-08-29 16:01:10 +0200 | [diff] [blame] | 109 | django_web: |
| 110 | # Run up action, any positional argument to docker-compose CLI |
| 111 | # If not defined, only docker-compose.yml is generated |
| 112 | status: up |
Filip Pytloun | be2b4a8 | 2016-09-15 18:10:24 +0200 | [diff] [blame] | 113 | # Run image pull every time state is run triggering container |
| 114 | # restart in case it's changed |
| 115 | pull: true |
Filip Pytloun | 96fc0cc | 2016-08-29 16:01:10 +0200 | [diff] [blame] | 116 | environment: |
| 117 | SOMEVAR: somevalue |
| 118 | service: |
| 119 | db: |
| 120 | image: postgres |
| 121 | web: |
| 122 | image: djangoapp |
| 123 | volumes: |
| 124 | - /srv/volumes/django:/srv/django |
| 125 | ports: |
| 126 | - 8000:8000 |
| 127 | depends_on: |
| 128 | - db |
| 129 | |
| 130 | |
Filip Pytloun | baf94c9 | 2016-06-07 18:07:17 +0200 | [diff] [blame] | 131 | Registry |
| 132 | -------- |
| 133 | |
| 134 | .. code-block:: yaml |
| 135 | |
| 136 | docker: |
| 137 | registry: |
| 138 | log: |
| 139 | level: debug |
| 140 | formatter: json |
| 141 | cache: |
| 142 | engine: redis |
| 143 | host: localhost |
| 144 | storage: |
| 145 | engine: filesystem |
| 146 | root: /srv/docker/registry |
| 147 | bind: |
| 148 | host: 0.0.0.0 |
| 149 | port: 5000 |
| 150 | hook: |
| 151 | mail: |
| 152 | levels: |
| 153 | - panic |
| 154 | # Options are rendered as yaml as is so use hook-specific options here |
| 155 | options: |
| 156 | smtp: |
| 157 | addr: smtp.sendhost.com:25 |
| 158 | username: sendername |
| 159 | password: password |
| 160 | insecure: true |
| 161 | from: name@sendhost.com |
| 162 | to: |
| 163 | - name@receivehost.com |
| 164 | |
marco | 85b72a6 | 2016-07-07 13:08:33 +0200 | [diff] [blame] | 165 | Docker login to private registry |
| 166 | -------------------------------- |
| 167 | |
| 168 | .. code-block:: yaml |
| 169 | |
| 170 | docker: |
| 171 | host: |
| 172 | enabled: true |
| 173 | registry: |
| 174 | first: |
| 175 | address: private.docker.com |
| 176 | user: username |
| 177 | password: password |
| 178 | second: |
| 179 | address: private2.docker.com |
| 180 | user: username2 |
| 181 | password: password2 |
Michael Kutý | 1764940 | 2016-03-19 23:57:43 +0100 | [diff] [blame] | 182 | |
| 183 | Read more |
| 184 | --------- |
| 185 | |
| 186 | * https://docs.docker.com/installation/ubuntulinux/ |
| 187 | * https://github.com/saltstack-formulas/docker-formula |
Filip Pytloun | baf94c9 | 2016-06-07 18:07:17 +0200 | [diff] [blame] | 188 | |