Differences between revisions 2 and 6 (spanning 4 versions)
Revision 2 as of 2020-06-26 20:07:06
Size: 1333
Comment:
Revision 6 as of 2021-11-18 09:22:22
Size: 1433
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 ==

----



== Configuration ==

----



== Compose Files ==



=== Volumes ===
Line 16: Line 34:
container name: CONTAINER container_name: CONTAINER
Line 31: Line 49:
container name: CONTAINER container_name: CONTAINER
Line 40: Line 58:
----

=== 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 76:
== Environment Variables == === Environment Variables ===
Line 46: Line 78:
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 81:
container name: CONTAINER container_name: CONTAINER

Docker Compose

Docker Compose is a method for creating containers through configuration files.


Installation


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


CategoryRicottone

Docker/Compose (last edited 2023-04-04 18:09:26 by DominicRicottone)