Changes

Docker

296 bytes added, 21:21, 25 June 2018
compose && swarm common part
There are three major versions of compose file format.
===compose && swarm common partonly===
* '''build''': Configuration options that are applied at build time
* '''image''': define the base image of the container.
* '''container_name''': define the name of the container that is created for the service.
{{note|
* '''commandcontainer_name''': Override Specify a custom container name, rather than a generated default name  * '''external_links''': Link to containers started outside this docker-compose.yml or even outside of Compose, especially for containers that provide shared or common services. external_links follow semantics similar to links when specifying both the container name and the default commandlink alias (CONTAINER:ALIAS). <pre>external_links: - redis_1 - project_db_1:mysql - project_db_1:postgresql</pre> command  * '''network_mode''': Network mode. Use the same values as the docker client --network parameter, plus the special form service: [service name].<pre>network_mode: "bundlebridge", network_mode: "exechost", network_mode: "thinnone", network_mode: "-pservice:[service name]", network_mode: "3000container:[container name/id]"] </pre>    ===compose && swarm common part===
* '''container_namecommand''': Specify a custom container nameOverride the default command. <pre> command: ["bundle", "exec", "thin", rather than a generated default name"-p", "3000"] </pre>
</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>
- ./apps/web.env
</pre>
 
 
* '''environment''': Add environment variables
<pre>
- "8000"
</pre>
  * '''extends''': Extend another service, in the current file or another, optionally overriding configuration.
<pre>
extends:
service: webapp <<extend this service
</pre>
* '''external_links''': Link to containers started outside this docker-compose.yml or even outside of Compose, especially for containers that provide shared or common services. external_links follow semantics similar to links when specifying both the container name and the link alias (CONTAINER:ALIAS).<pre>external_links: - redis_1 - project_db_1:mysql - project_db_1:postgresql</pre>
* '''extra_hosts''': Add hostname mappings. Use the same values as the docker client --add-host parameter.
<pre>
- "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>
- "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.
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>
 
 
 
=== swarm ===