Size: 1333
Comment:
|
Size: 1622
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
'''Docker Compose''' is a method for creating containers through configuration files. |
|
Line 9: | Line 11: |
== Volumes == | == Installation == Most [[Linux]] distributions offer a `docker-compose` package. ---- == Configuration == ---- == Compose Files == === Volumes === |
Line 16: | Line 36: |
container name: CONTAINER | container_name: CONTAINER |
Line 31: | Line 51: |
container name: CONTAINER | container_name: CONTAINER |
Line 40: | Line 60: |
---- | === Port Management === To give a container access to ports, use: {{{ container_name: CONTAINER version: 0.1 services: web: image: IMAGE ports: - 8888:8888 }}} |
Line 44: | Line 78: |
== Environment Variables == | === Environment Variables === |
Line 46: | Line 80: |
Environment variables are typically passed into Docker as a way to securely provide authentication, i.e. [[MariaDBConfiguration|the root password for MariaDB]]. It would be antithetical to security to have the variables set within the Docker Compose file. Instead, instruct Docker Compose to ''pass in'' a variable that is set already in the local user's environment. | To pass in an environment variable from the local environment to a Docker container, use: |
Line 49: | Line 83: |
container name: CONTAINER | container_name: CONTAINER |
Line 59: | Line 93: |
---- == See also == [[https://docs.docker.com/compose/compose-file/|Docker com,pose reference documentation]] |
Docker Compose
Docker Compose is a method for creating containers through configuration files.
Contents
Installation
Most Linux distributions offer a docker-compose package.
Configuration
Compose Files
Volumes
Docker supports two methods for binding volumes, hereafter referred to as the 'long syntax' and the 'short syntax'. Docker Compose supports two parallel methods. Upstream recommendation is to use the long syntax.
The long syntax is as follows:
container_name: CONTAINER version: 0.1 services: web: image: IMAGE volumes: - type: bind source: relative/source/path target: /absolute/target/path read only: true
The short syntax is as follows:
container_name: CONTAINER version: 0.1 services: web: image: IMAGE volumes: - relative/source/path:/absolute/target/path:ro
Port Management
To give a container access to ports, use:
container_name: CONTAINER version: 0.1 services: web: image: IMAGE ports: - 8888:8888
Environment Variables
To pass in an environment variable from the local environment to a Docker container, use:
container_name: CONTAINER version: 0.1 services: web: image: IMAGE environment: - VARIABLE1 - VARIABLE2
See also
Docker com,pose reference documentation