add docker compose example

This commit is contained in:
Lee 2023-06-26 13:42:14 +01:00
parent 8e7d0717ea
commit db2c80620a

@ -0,0 +1,54 @@
---
title: How to use Docker Compose
description:
published: true
date: 2023-06-26T13:38:49.025Z
tags: docker, ubuntu, containerization, container, linux, server
editor: markdown
dateCreated: 2023-06-26T13:38:49.025Z
---
# How to use Docker Compose
Examples for using Docker Compose, specifically tested on Ubuntu 22.04.
## Prerequisites
- Docker installed on your system
- A user account with sudo privileges
## Examples
Base docker-compose.yml file:
```bash
version: "3"
services:
<service_name>:
image: <image>
container_name: <container_name>
restart: <restart-policy>
ports:
- "<host>:<container>"
volumes:
- <host>:<container>
environment:
- <key>=<value>
```
Nginx docker-compose.yml example:
```bash
version: "3"
services:
nginx:
image: nginx:latest
container_name: nginx
restart: always
ports:
- "80:80"
volumes:
- /home/nginx:/var/www/html
environment:
- TZ=Europe/London
```