# Docker-Compose ... ## Networking By default Docker-Compose will create a new network for the given compose file. You can change the behavior by defining custom networks in your compose file. ### Create and assign custom network ... *Example:* ```yaml networks: custom-network: services: app: networks: - custom-network ``` ### Use existing networks If you want to use an existing Docker network for your compose files, you can add the `external: true` parameter in your compose file *Example:* ```yaml networks: existing-network: external: true ``` ## Volumes Volumes are data storage objects that Docker containers can use for persistent storage. ### Create and map static volume(s) ```yaml volumes: my-volume: services: app: volumes: - my-volume:/path-in-container ``` These volumes are stored in `/var/lib/docker/volumes`. ### Create volume that is a CIFS mount to external share ```yaml # Variables that will need to be changed: # - User id for folder/file permissions # - Group id for folder/file permissions # - Path where Unmanic will store config files # - Cache path for in-progress encoding tasks # - Remote IP address of CIFS mount # - Path in remote machine to be mounted as your library # - Remote mount username # - Remote mount password # --- version: '2.4' services: app: container_name: app_name image: repo/app:tag ports: - 1234:1234 environment: - PUID= - PGID= volumes: - cifs_mount:/path-in-container volumes: cifs_mount: driver: local driver_opts: type: cifs device: /// o: "username=,password=,vers=3.0,uid=,gid=" ``` ## Environment Variables Environment variables can be defined in the `environment` section of a service in a Docker Compose file. ### Define environment variables ```yaml services: app: environment: - ENV_VAR=value ``` ### Interpolate environment variables | Variable | Description | | --- | --- | | `${ENV_VAR}` | Value of `ENV_VAR` | | `${ENV_VAR:-default}` | Value of `ENV_VAR` if set and non-empty, otherwise `default`| | `${ENV_VAR-default}` | Value of `ENV_VAR` if set, otherwise `default`| | `${ENV_VAR:?error}` | Value of `ENV_VAR` if set and non-empty, otherwise exit with `error` | | `${ENV_VAR?error}` | Value of `ENV_VAR` if set, otherwise exit with `error` | | `${ENV_VAR:+replacement}` | `replacement` if `ENV_VAR` is set and non-empty, otherwise empty | | `${ENV_VAR+replacement}` | `replacement` if `ENV_VAR` is set, otherwise empty |