Changes

Docker

3,350 bytes added, 21:26, 25 June 2018
Good to know
<br>
<br>
 
===compose && swarm common part===
<br>
 
* '''command''': Override the default command. <pre> command: ["bundle", "exec", "thin", "-p", "3000"] </pre>
 
 
* '''dns''': Custom DNS servers. Can be a single value or a list.
<pre>
dns: 8.8.8.8
dns:
- 8.8.8.8
- 9.9.9.9
</pre>
 
 
* '''dns_search''': Custom DNS search domains. Can be a single value or a list.
<pre>
dns_search: example.com
dns_search:
- dc1.example.com
- dc2.example.com
</pre>
* '''entrypoint''': Override the default entrypoint.
<pre>
entrypoint: /code/entrypoint.sh
or as a list:
entrypoint:
- php
- -d
</pre>
<span style="color: red>Note: Setting entrypoint both overrides any default entrypoint set on the service’s image with the ENTRYPOINT Dockerfile instruction, and clears out any default command on the image - meaning that if there’s a CMD instruction in the Dockerfile, it is ignored.</span>
 
 
* '''env_file''': Add environment variables from a file. Can be a single value or a list.
<pre>
env_file:
- ./common.env
- ./apps/web.env
</pre>
 
 
* '''environment''': Add environment variables
<pre>
environment:
- RACK_ENV=development
- SHOW=true
</pre>
* '''expose''': Expose ports without publishing them to the host machine - they’ll only be accessible to linked services. Only the internal port can be specified.
<pre>
expose:
- "3000"
- "8000"
</pre>
 
 
* '''extends''': Extend another service, in the current file or another, optionally overriding configuration.
<pre>
extends:
file: common.yml <<from this file
service: webapp <<extend this service
</pre>
 
 
 
 
 
* '''extra_hosts''': Add hostname mappings. Use the same values as the docker client --add-host parameter.
<pre>
extra_hosts:
- "somehost:162.242.195.82"
- "otherhost:50.31.209.229"
</pre>
 
 
* '''image''': Specify the image to start the container from. Can either be a repository/tag or a partial image ID.If the image does not exist, Compose attempts to pull it
<span style="color: red>Note: In the version 1 file format, using build together with image is not allowed. Attempting to do so results in an error.</span>
* '''labels''': Add metadata to containers using Docker labels. You can use either an array or a dictionary.
<pre>
labels:
- "com.example.description=Accounting webapp"
- "com.example.department=Finance"
</pre>
 
 
* '''links''': Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name.
 
<span style="color: red>Links are a legacy option. We recommend using networks instead.</span>
<pre>
web:
links:
- db
- db:database
- redis
</pre>
Containers for the linked service are reachable at a hostname identical to the alias, or the service name if no alias was specified.
Links also express dependency between services in the same way as depends_on, so they determine the order of service startup.
<span style="color: red>Note: If you define both links and networks, services with links between them must share at least one network in common in order to communicate.</span>
 
 
* '''networks''': Networks to join. The container created from this service will be connected to the given network(s). (web to new, worker to legacy)
<pre>
services:
web:
build: ./web
networks:
- new
 
worker:
build: ./worker
networks:
- legacy
</pre>
 
<hr>
 
==Good to know==