Size: 634
Comment:
|
Size: 1551
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 and the Docker daemon. Everything that Docker Compose does, you can also do through interactive execution. As such, this page runs in parallel to the [[DockerContainersSetup|docker container setup page]]. |
|
Line 9: | Line 11: |
== 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 }}} ---- |
|
Line 11: | Line 66: |
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 14: | Line 69: |
container name: CONTAINER | container_name: CONTAINER |
Docker Compose
Docker Compose is a method for creating containers through configuration files and the Docker daemon. Everything that Docker Compose does, you can also do through interactive execution. As such, this page runs in parallel to the docker container setup page.
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