Changes

Jump to: navigation, search

Docker

2,349 bytes added, 21:49, 24 June 2018
docker-compose.yml syntax
- -d
</pre>
<span style="color: red>Note: </span> 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.
* '''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>
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>
* '''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>
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:</span> In the version 1 file format, using build together with image is not allowed. Attempting to do so results in an error.
* '''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.
 
Links are a legacy option. We recommend using networks instead.
 
web:
links:
- db
- db:database
- redis
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.
 
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.
 

Navigation menu