Differences between revisions 3 and 8 (spanning 5 versions)
Revision 3 as of 2020-07-06 02:56:08
Size: 1551
Comment:
Revision 8 as of 2023-04-04 17:33:40
Size: 1622
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
'''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]]. '''Docker Compose''' is a method for creating containers through configuration files.
Line 11: Line 11:
== Volumes == == Installation ==

Most [[Linux]] distributions offer a `docker-compose` package.

----



== Configuration ==

----



== Compose Files ==



=== Volumes ===
Line 18: Line 36:
container name: CONTAINER container_name: CONTAINER
Line 33: Line 51:
container name: CONTAINER container_name: CONTAINER
Line 42: Line 60:
----
Line 45: Line 62:

== Port Management ==
=== Port Management ===
Line 51: Line 67:
container name: CONTAINER container_name: CONTAINER
Line 60: Line 76:
----
Line 63: Line 78:

== Environment Variables ==
=== Environment Variables ===
Line 69: Line 83:
container name: CONTAINER container_name: CONTAINER
Line 79: 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.


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


CategoryRicottone

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