Adopt Compose v2 (#240)

* Adopt Compose v2

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
master
Nicolas De loof 3 years ago committed by GitHub
parent bc95525543
commit 667bd9facb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -84,12 +84,12 @@ deploying samples of containerized applications with Docker Compose.
### Running a sample ### Running a sample
The root directory of each sample contains the `docker-compose.yaml` which The root directory of each sample contains the `compose.yaml` which
describes the configuration of service components. All samples can be run in describes the configuration of service components. All samples can be run in
a local environment by going into the root directory of each one and executing: a local environment by going into the root directory of each one and executing:
```console ```console
docker-compose up -d docker compose up -d
``` ```
Check the `README.md` of each sample to get more details on the structure and Check the `README.md` of each sample to get more details on the structure and
@ -97,7 +97,7 @@ what is the expected output.
To stop and remove all containers of the sample application run: To stop and remove all containers of the sample application run:
```console ```console
docker-compose down docker compose down
``` ```
<!--lint disable awesome-toc--> <!--lint disable awesome-toc-->
## Contribute ## Contribute

@ -9,10 +9,10 @@ Project structure:
│   ├── ... │   ├── ...
│   ├── ... │   ├── ...
│   .... │   ....
└── docker-compose.yaml └── compose.yaml
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
web: web:
@ -24,14 +24,14 @@ services:
``` ```
The compose file defines an application with one service `angular`. The image for the service is built with the Dockerfile inside the `angular` directory (build parameter). The compose file defines an application with one service `angular`. The image for the service is built with the Dockerfile inside the `angular` directory (build parameter).
When deploying the application, docker-compose maps the container port 4200 to the same port on the host as specified in the file. When deploying the application, docker compose maps the container port 4200 to the same port on the host as specified in the file.
Make sure port 4200 is not being used by another container, otherwise the port should be changed. Make sure port 4200 is not being used by another container, otherwise the port should be changed.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "angular_default" with the default driver Creating network "angular_default" with the default driver
Building angular Building angular
Step 1/7 : FROM node:10 Step 1/7 : FROM node:10
@ -63,5 +63,5 @@ After the application starts, navigate to `http://localhost:4200` in your web br
Stop and remove the container Stop and remove the container
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -4,14 +4,14 @@
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
├── app ├── app
   ├── Dockerfile    ├── Dockerfile
   └── index.php    └── index.php
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
web: web:
@ -22,10 +22,10 @@ services:
- ./app:/var/www/html/ - ./app:/var/www/html/
``` ```
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "php-docker_web" with the default driver Creating network "php-docker_web" with the default driver
Building web Building web
Step 1/6 : FROM php:7.2-apache Step 1/6 : FROM php:7.2-apache
@ -52,5 +52,5 @@ Hello World!
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -9,10 +9,10 @@ Project structure:
| | └── ... | | └── ...
│   ├── ... │   ├── ...
│   └── Dockerfile │   └── Dockerfile
└── docker-compose.yaml └── compose.yaml
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
web: web:
@ -28,7 +28,7 @@ services:
``` ```
The compose file defines an application with two services `web` and `db`. The image for the web service is built with the Dockerfile inside the `app` directory (build parameter). The compose file defines an application with two services `web` and `db`. The image for the web service is built with the Dockerfile inside the `app` directory (build parameter).
When deploying the application, docker-compose maps the container port 80 to port 80 of the host as specified in the file. When deploying the application, docker compose maps the container port 80 to port 80 of the host as specified in the file.
Make sure port 80 on the host is not being used by another container, otherwise the port should be changed. Make sure port 80 on the host is not being used by another container, otherwise the port should be changed.
> **_INFO_** > **_INFO_**
@ -36,10 +36,10 @@ Make sure port 80 on the host is not being used by another container, otherwise
> You still can use the MS SQL Server image by uncommenting the following line in the Compose file > You still can use the MS SQL Server image by uncommenting the following line in the Compose file
> `#image: mcr.microsoft.com/mssql/server` > `#image: mcr.microsoft.com/mssql/server`
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "aspnet-mssql_default" with the default driver Creating network "aspnet-mssql_default" with the default driver
Building web Building web
Step 1/13 : FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build Step 1/13 : FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
@ -71,5 +71,5 @@ After the application starts, navigate to `http://localhost:80` in your web brow
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -4,7 +4,7 @@
Project structure: Project structure:
``` ```
. .
├── docker-compose.yml ├── compose.yaml
├── app ├── app
   ├── Dockerfile    ├── Dockerfile
   ├── requirements.txt    ├── requirements.txt
@ -12,7 +12,7 @@ Project structure:
``` ```
[_docker-compose.yml_](docker-compose.yml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
web: web:
@ -21,10 +21,10 @@ services:
- '8000:8000' - '8000:8000'
``` ```
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "django_default" with the default driver Creating network "django_default" with the default driver
Building web Building web
Step 1/6 : FROM python:3.7-alpine Step 1/6 : FROM python:3.7-alpine
@ -48,5 +48,5 @@ After the application starts, navigate to `http://localhost:8000` in your web br
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -4,10 +4,10 @@
Project structure: Project structure:
``` ```
. .
└── docker-compose.yml └── compose.yaml
``` ```
[_docker-compose.yml_](docker-compose.yml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
elasticsearch: elasticsearch:
@ -21,10 +21,10 @@ services:
... ...
``` ```
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "elasticsearch-logstash-kibana_elastic" with driver "bridge" Creating network "elasticsearch-logstash-kibana_elastic" with driver "bridge"
Creating es ... done Creating es ... done
Creating log ... done Creating log ... done
@ -50,7 +50,7 @@ After the application starts, navigate to below links in your web browser:
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```
## Attribution ## Attribution

@ -3,7 +3,7 @@
Project structure: Project structure:
``` ```
├── docker-compose.yaml ├── compose.yaml
├── Dockerfile ├── Dockerfile
├── requirements.txt ├── requirements.txt
├── app ├── app
@ -12,7 +12,7 @@ Project structure:
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
api: api:
@ -26,7 +26,7 @@ services:
``` ```
## Deploy with docker-compose ## Deploy with docker compose
```shell ```shell
docker-compose up -d --build docker-compose up -d --build
@ -49,7 +49,7 @@ After the application starts, navigate to `http://localhost:8000` in your web br
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -9,11 +9,11 @@ Project structure:
├── Dockerfile ├── Dockerfile
├── README.md ├── README.md
├── app.py ├── app.py
├── docker-compose.yml ├── compose.yaml
└── requirements.txt └── requirements.txt
``` ```
[_docker-compose.yml_](docker-compose.yml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
@ -31,10 +31,10 @@ services:
- redis - redis
``` ```
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
[+] Running 24/24 [+] Running 24/24
⠿ redis Pulled ⠿ redis Pulled
... ...
@ -52,7 +52,7 @@ $ docker-compose up -d
Listing containers must show one container running and the port mapping as below: Listing containers must show one container running and the port mapping as below:
``` ```
$ docker-compose ps $ docker compose ps
NAME COMMAND SERVICE STATUS PORTS NAME COMMAND SERVICE STATUS PORTS
flask-redis-redis-1 "redis-server --load…" redis running 0.0.0.0:6379->6379/tcp flask-redis-redis-1 "redis-server --load…" redis running 0.0.0.0:6379->6379/tcp
flask-redis-web-1 "/bin/sh -c 'python …" web running 0.0.0.0:5000->5000/tcp flask-redis-web-1 "/bin/sh -c 'python …" web running 0.0.0.0:5000->5000/tcp
@ -78,5 +78,5 @@ OK
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -4,7 +4,7 @@
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
├── app ├── app
   ├── Dockerfile    ├── Dockerfile
   ├── requirements.txt    ├── requirements.txt
@ -12,7 +12,7 @@ Project structure:
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
web: web:
@ -21,10 +21,10 @@ services:
- '5000:5000' - '5000:5000'
``` ```
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "flask_default" with the default driver Creating network "flask_default" with the default driver
Building web Building web
Step 1/6 : FROM python:3.7-alpine Step 1/6 : FROM python:3.7-alpine
@ -52,5 +52,5 @@ Hello World!
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -5,11 +5,11 @@ This example defines one of the base setups for Gitea. More details on how to cu
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
gitea: gitea:
@ -23,13 +23,13 @@ services:
... ...
``` ```
When deploying this setup, docker-compose maps the gitea container port 3000 to When deploying this setup, docker compose maps the gitea container port 3000 to
the same port of the host as specified in the compose file. the same port of the host as specified in the compose file.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker$ compose up -d $ docker compose up -d
Creating network "gitea-postgres_default" with the default driver Creating network "gitea-postgres_default" with the default driver
Creating gitea-postgres_db_1 ... done Creating gitea-postgres_db_1 ... done
Creating gitea-postgres_gitea_1 ... done Creating gitea-postgres_gitea_1 ... done
@ -58,10 +58,10 @@ Gitea service.
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```
To remove all Gitea data, delete the named volumes by passing the `-v` parameter: To remove all Gitea data, delete the named volumes by passing the `-v` parameter:
``` ```
$ docker-compose down -v $ docker compose down -v
``` ```

@ -4,11 +4,11 @@ This example defines a basic setup for a Minecraft server. More details on the M
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
minecraft: minecraft:
@ -20,15 +20,15 @@ services:
- "~/minecraft_data:/data" - "~/minecraft_data:/data"
``` ```
When deploying this setup, docker-compose maps the Minecraft server port 25565 to When deploying this setup, docker compose maps the Minecraft server port 25565 to
the same port of the host as specified in the compose file. The Minecraft client application can connect to this port directly. the same port of the host as specified in the compose file. The Minecraft client application can connect to this port directly.
This example maps the Minecraft data folder holding all game storage to ~/minecraft_data on the host. This example maps the Minecraft data folder holding all game storage to ~/minecraft_data on the host.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ mkdir -p ~/minecraft_data $ mkdir -p ~/minecraft_data
$ docker-compose up -d $ docker compose up -d
WARNING: Some services (minecraft) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm. WARNING: Some services (minecraft) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
Creating network "minecraft_default" with the default driver Creating network "minecraft_default" with the default driver
Creating minecraft_minecraft_1 ... done Creating minecraft_minecraft_1 ... done
@ -49,7 +49,7 @@ CONTAINER ID IMAGE COMMAND CREATED
After running `docker-compose up`, the minecraft server takes a bit of time to initialize Minecraft world. You can follow the progress: After running `docker-compose up`, the minecraft server takes a bit of time to initialize Minecraft world. You can follow the progress:
``` ```
$ docker-compose logs $ docker compose logs
... ...
minecraft_1 | [15:06:39] [Worker-Main-6/INFO]: Preparing spawn area: 94% minecraft_1 | [15:06:39] [Worker-Main-6/INFO]: Preparing spawn area: 94%
minecraft_1 | [15:06:39] [Worker-Main-7/INFO]: Preparing spawn area: 94% minecraft_1 | [15:06:39] [Worker-Main-7/INFO]: Preparing spawn area: 94%
@ -72,11 +72,11 @@ Once it is initialized, run your Minecraft application, hit "Play", then "Multip
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```
To delete all data, remove all named volumes by passing the -v arguments: To delete all data, remove all named volumes by passing the -v arguments:
``` ```
$ docker-compose down -v $ docker compose down -v
``` ```

@ -7,11 +7,11 @@ further customize the installation and the compose file can be found on the
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
nc: nc:
@ -24,13 +24,13 @@ services:
... ...
``` ```
When deploying this setup, docker-compose maps the nextcloud container port 80 to When deploying this setup, docker compose maps the nextcloud container port 80 to
port 80 of the host as specified in the compose file. port 80 of the host as specified in the compose file.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker$ compose up -d $ docker compose up -d
Creating network "nextcloud-postgres_default" with the default driver Creating network "nextcloud-postgres_default" with the default driver
Creating volume "nextcloud-postgres_nc_data" with default driver Creating volume "nextcloud-postgres_nc_data" with default driver
Pulling nc (nextcloud:apache)... Pulling nc (nextcloud:apache)...
@ -60,5 +60,5 @@ Nextcloud service.
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -7,11 +7,11 @@ further customize the installation and the compose file can be found on the
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
nc: nc:
@ -29,13 +29,13 @@ services:
... ...
``` ```
When deploying this setup, docker-compose maps the nextcloud container port 80 to When deploying this setup, docker compose maps the nextcloud container port 80 to
port 80 of the host as specified in the compose file. port 80 of the host as specified in the compose file.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker$ compose up -d $ docker compose up -d
Creating network "nextcloud-redis-mariadb_redisnet" with the default driver Creating network "nextcloud-redis-mariadb_redisnet" with the default driver
Creating network "nextcloud-redis-mariadb_dbnet" with the default driver Creating network "nextcloud-redis-mariadb_dbnet" with the default driver
Creating volume "nextcloud-redis-mariadb_nc_data" with default driver Creating volume "nextcloud-redis-mariadb_nc_data" with default driver
@ -68,10 +68,10 @@ Nextcloud service.
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```
To delete all data, remove all named volumes by passing the `-v` arguments: To delete all data, remove all named volumes by passing the `-v` arguments:
``` ```
$ docker-compose down -v $ docker compose down -v
``` ```

@ -10,14 +10,14 @@ Project structure:
│   └── Program.cs │   └── Program.cs
├── db ├── db
│   └── password.txt │   └── password.txt
├── docker-compose.yaml ├── compose.yaml
├── proxy ├── proxy
│   ├── conf │   ├── conf
│   └── Dockerfile │   └── Dockerfile
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -36,7 +36,7 @@ services:
... ...
``` ```
The compose file defines an application with three services `proxy`, `backend` and `db`. The compose file defines an application with three services `proxy`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use. Make sure port 80 on the host is not already being in use.
> **_INFO_** > **_INFO_**
@ -44,10 +44,10 @@ Make sure port 80 on the host is not already being in use.
> You still can use the MySQL image by uncommenting the following line in the Compose file > You still can use the MySQL image by uncommenting the following line in the Compose file
> `#image: mysql:8.0.27` > `#image: mysql:8.0.27`
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
``` ```
## Expected result ## Expected result
@ -72,5 +72,5 @@ $ curl localhost:80
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -4,7 +4,7 @@
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
├── flask ├── flask
│   ├── Dockerfile │   ├── Dockerfile
│   ├── requirements.txt │   ├── requirements.txt
@ -14,7 +14,7 @@ Project structure:
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
web: web:
@ -28,13 +28,13 @@ services:
image: mongo image: mongo
``` ```
The compose file defines an application with three services `web`, `backend` and `db`. The compose file defines an application with three services `web`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the web service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 80 of the web service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not being used by another container, otherwise the port should be changed. Make sure port 80 on the host is not being used by another container, otherwise the port should be changed.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "nginx-flask-mongo_default" with the default driver Creating network "nginx-flask-mongo_default" with the default driver
Pulling mongo (mongo:)... Pulling mongo (mongo:)...
latest: Pulling from library/mongo latest: Pulling from library/mongo
@ -67,5 +67,5 @@ Hello from the MongoDB client!
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -4,7 +4,7 @@
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
├── flask ├── flask
│   ├── Dockerfile │   ├── Dockerfile
│   ├── requirements.txt │   ├── requirements.txt
@ -14,7 +14,7 @@ Project structure:
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -31,7 +31,7 @@ services:
... ...
``` ```
The compose file defines an application with three services `proxy`, `backend` and `db`. The compose file defines an application with three services `proxy`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use. Make sure port 80 on the host is not already being in use.
> **_INFO_** > **_INFO_**
@ -39,10 +39,10 @@ Make sure port 80 on the host is not already being in use.
> You still can use the MySQL image by uncommenting the following line in the Compose file > You still can use the MySQL image by uncommenting the following line in the Compose file
> `#image: mysql:8.0.27` > `#image: mysql:8.0.27`
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "nginx-flask-mysql_default" with the default driver Creating network "nginx-flask-mysql_default" with the default driver
Pulling db (mysql:8.0.19)... Pulling db (mysql:8.0.19)...
5.7: Pulling from library/mysql 5.7: Pulling from library/mysql
@ -75,5 +75,5 @@ $ curl localhost:80
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -9,7 +9,7 @@ class DBManager:
self.connection = mysql.connector.connect( self.connection = mysql.connector.connect(
user=user, user=user,
password=pf.read(), password=pf.read(),
host=host, # name of the mysql service as set in the docker-compose file host=host, # name of the mysql service as set in the docker compose file
database=database, database=database,
auth_plugin='mysql_native_password' auth_plugin='mysql_native_password'
) )

@ -10,14 +10,14 @@ Project structure:
│   └── main.go │   └── main.go
├── db ├── db
│   └── password.txt │   └── password.txt
├── docker-compose.yaml ├── compose.yaml
├── proxy ├── proxy
│   ├── conf │   ├── conf
│   └── Dockerfile │   └── Dockerfile
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -36,7 +36,7 @@ services:
... ...
``` ```
The compose file defines an application with three services `proxy`, `backend` and `db`. The compose file defines an application with three services `proxy`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use. Make sure port 80 on the host is not already being in use.
> **_INFO_** > **_INFO_**
@ -44,10 +44,10 @@ Make sure port 80 on the host is not already being in use.
> You still can use the MySQL image by uncommenting the following line in the Compose file > You still can use the MySQL image by uncommenting the following line in the Compose file
> `#image: mysql:8.0.27` > `#image: mysql:8.0.27`
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "nginx-golang-mysql_default" with the default driver Creating network "nginx-golang-mysql_default" with the default driver
Building backend Building backend
Step 1/8 : FROM golang:1.13-alpine AS build Step 1/8 : FROM golang:1.13-alpine AS build
@ -83,5 +83,5 @@ $ curl localhost:80
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -10,14 +10,14 @@ Project structure:
│   └── main.go │   └── main.go
├── db ├── db
│   └── password.txt │   └── password.txt
├── docker-compose.yaml ├── compose.yaml
├── proxy ├── proxy
│   ├── conf │   ├── conf
│   └── Dockerfile │   └── Dockerfile
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -33,13 +33,13 @@ services:
... ...
``` ```
The compose file defines an application with three services `proxy`, `backend` and `db`. The compose file defines an application with three services `proxy`, `backend` and `db`.
When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not already being in use. Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "nginx-golang-postgres_default" with the default driver Creating network "nginx-golang-postgres_default" with the default driver
Pulling db (postgres:)... Pulling db (postgres:)...
latest: Pulling from library/postgres latest: Pulling from library/postgres
@ -71,5 +71,5 @@ $ curl localhost:80
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -7,14 +7,14 @@ Project structure:
├── backend ├── backend
│   ├── Dockerfile │   ├── Dockerfile
│   └── main.go │   └── main.go
├── docker-compose.yml ├── compose.yaml
├── frontend ├── frontend
│   ├── Dockerfile │   ├── Dockerfile
│   └── nginx.conf │   └── nginx.conf
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
frontend: frontend:
@ -27,13 +27,13 @@ services:
build: backend build: backend
``` ```
The compose file defines an application with two services `frontend` and `backend`. The compose file defines an application with two services `frontend` and `backend`.
When deploying the application, docker-compose maps port 80 of the frontend service container to the same port of the host as specified in the file. When deploying the application, docker compose maps port 80 of the frontend service container to the same port of the host as specified in the file.
Make sure port 80 on the host is not already in use. Make sure port 80 on the host is not already in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "nginx-golang_default" with the default driver Creating network "nginx-golang_default" with the default driver
Building backend Building backend
Step 1/7 : FROM golang:1.13 AS build Step 1/7 : FROM golang:1.13 AS build
@ -75,5 +75,5 @@ Hello from Docker!
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -6,7 +6,7 @@ Project structure:
``` ```
. .
├── README.md ├── README.md
├── docker-compose.yml ├── compose.yaml
├── nginx ├── nginx
│   ├── Dockerfile │   ├── Dockerfile
│   └── nginx.conf │   └── nginx.conf
@ -19,7 +19,7 @@ Project structure:
``` ```
[_docker-compose.yml_](docker-compose.yml) [_compose.yaml_](compose.yaml)
``` ```
redis: redis:
image: 'redislabs/redismod' image: 'redislabs/redismod'
@ -46,16 +46,16 @@ redis:
- web2 - web2
``` ```
The compose file defines an application with four services `redis`, `nginx`, `web1` and `web2`. The compose file defines an application with four services `redis`, `nginx`, `web1` and `web2`.
When deploying the application, docker-compose maps port 80 of the nginx service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 80 of the nginx service container to port 80 of the host as specified in the file.
> **_INFO_** > **_INFO_**
> Redis runs on port 6379 by default. Make sure port 6379 on the host is not being used by another container, otherwise the port should be changed. > Redis runs on port 6379 by default. Make sure port 6379 on the host is not being used by another container, otherwise the port should be changed.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
[+] Running 24/24 [+] Running 24/24
⠿ redis Pulled ... ⠿ redis Pulled ...
⠿ 565225d89260 Pull complete ⠿ 565225d89260 Pull complete
@ -103,6 +103,6 @@ web2: Total number of visits is: 3
## Stop and remove the containers ## Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -6,7 +6,7 @@ Project structure:
```text ```text
. .
├── docker-compose.yaml ├── compose.yaml
├── flask ├── flask
│   ├── app.py │   ├── app.py
│   ├── Dockerfile │   ├── Dockerfile
@ -19,7 +19,7 @@ Project structure:
   └── start.sh    └── start.sh
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
```yml ```yml
services: services:
@ -33,14 +33,14 @@ services:
``` ```
The compose file defines an application with two services `nginx-proxy` and `flask-app`. The compose file defines an application with two services `nginx-proxy` and `flask-app`.
When deploying the application, docker-compose maps port 80 of the web service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 80 of the web service container to port 80 of the host as specified in the file.
Make sure port 80 on the host is not being used by another container, otherwise the port should be changed. Make sure port 80 on the host is not being used by another container, otherwise the port should be changed.
## Deploy with docker-compose ## Deploy with docker compose
```bash ```bash
$ docker-compose up -d $ docker compose up -d
Creating network "nginx-wsgi-flask_default" with the default driver Creating network "nginx-wsgi-flask_default" with the default driver
Building flask-app Building flask-app
... ...
@ -71,7 +71,7 @@ Hello World!
Stop and remove the containers Stop and remove the containers
```bash ```bash
$ docker-compose down $ docker compose down
Stopping nginx-wsgi-flask_nginx-proxy_1 ... done Stopping nginx-wsgi-flask_nginx-proxy_1 ... done
Stopping nginx-wsgi-flask_flask-app_1 ... done Stopping nginx-wsgi-flask_flask-app_1 ... done
Removing nginx-wsgi-flask_nginx-proxy_1 ... done Removing nginx-wsgi-flask_nginx-proxy_1 ... done

@ -7,11 +7,11 @@ Project structure:
``` ```
. .
├── .env ├── .env
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` yaml ``` yaml
services: services:
pihole: pihole:
@ -46,18 +46,18 @@ Before deploying this setup, you need to configure the following values in the [
If you would like to disable conditional forwarding, delete the environment variables starting with "CONDITIONAL_FORWARDING" If you would like to disable conditional forwarding, delete the environment variables starting with "CONDITIONAL_FORWARDING"
### Container DNS (optional, default: disabled) ### Container DNS (optional, default: disabled)
In the docker-compose file, dns is added as a comment. To enable dns remove '#' in front of the following lines: In the docker compose file, dns is added as a comment. To enable dns remove '#' in front of the following lines:
``` yaml ``` yaml
dns: dns:
- 127.0.0.1 # "Sets your container's resolve settings to localhost so it can resolve DHCP hostnames [...]" - github.com/pi-hole/docker-pi-hole - 127.0.0.1 # "Sets your container's resolve settings to localhost so it can resolve DHCP hostnames [...]" - github.com/pi-hole/docker-pi-hole
- 1.1.1.1 # Backup server - 1.1.1.1 # Backup server
``` ```
## Deploy with docker-compose ## Deploy with docker compose
When deploying this setup, the admin web interface will be available on port 8080 (e.g. http://localhost:8080/admin). When deploying this setup, the admin web interface will be available on port 8080 (e.g. http://localhost:8080/admin).
``` shell ``` shell
$ docker-compose up -d $ docker compose up -d
Starting cloudflared ... done Starting cloudflared ... done
Starting pihole ... done Starting pihole ... done
``` ```
@ -78,9 +78,9 @@ Navigate to `http://localhost:8080` in your web browser to access the installed
Stop the containers with Stop the containers with
``` shell ``` shell
$ docker-compose down $ docker compose down
# To delete all data run: # To delete all data run:
$ docker-compose down -v $ docker compose down -v
``` ```
## Troubleshooting ## Troubleshooting

@ -8,11 +8,11 @@ Project structure:
``` ```
. .
├── .env ├── .env
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` yaml ``` yaml
services: services:
plex: plex:
@ -28,11 +28,11 @@ Before deploying this setup, you need to configure the following values in the [
### Hardware Acceleration ### Hardware Acceleration
Check out the description for Hardware Acceleration support in the [documentation](https://github.com/linuxserver/docker-plex). Check out the description for Hardware Acceleration support in the [documentation](https://github.com/linuxserver/docker-plex).
## Deploy with docker-compose ## Deploy with docker compose
When deploying this setup, the web interface will be available on port 32400 (e.g. http://localhost:32400/web). When deploying this setup, the web interface will be available on port 32400 (e.g. http://localhost:32400/web).
``` shell ``` shell
$ docker-compose up -d $ docker compose up -d
Starting plex ... done Starting plex ... done
``` ```
@ -51,7 +51,7 @@ Navigate to `http://localhost:32400/web` in your web browser to access the plex
Stop the containers with Stop the containers with
``` shell ``` shell
$ docker-compose down $ docker compose down
# To delete all data run: # To delete all data run:
$ docker-compose down -v $ docker compose down -v
``` ```

@ -10,22 +10,22 @@ You can try out the public demo instance first: http://demo.portainer.io/
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` yaml ``` yaml
services: services:
portainer: portainer:
image: portainer/portainer-ce:alpine image: portainer/portainer-ce:alpine
``` ```
## Deploy with docker-compose ## Deploy with docker compose
When deploying this setup, the web interface will be available on port 9000 (e.g. http://localhost:9000). When deploying this setup, the web interface will be available on port 9000 (e.g. http://localhost:9000).
``` shell ``` shell
$ docker-compose up -d $ docker compose up -d
Starting portainer ... done Starting portainer ... done
``` ```
@ -45,9 +45,9 @@ Navigate to `http://localhost:9000` in your web browser to access the portainer
Stop the containers with Stop the containers with
``` shell ``` shell
$ docker-compose down $ docker compose down
# To delete all data run: # To delete all data run:
$ docker-compose down -v $ docker compose down -v
``` ```
## Troubleshooting ## Troubleshooting

@ -6,11 +6,11 @@ Project structure:
``` ```
. .
├── .env ├── .env
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` yaml ``` yaml
services: services:
postgres: postgres:
@ -30,11 +30,11 @@ Before deploying this setup, you need to configure the following values in the [
- PGADMIN_MAIL - PGADMIN_MAIL
- PGADMIN_PW - PGADMIN_PW
## Deploy with docker-compose ## Deploy with docker compose
When deploying this setup, the pgAdmin web interface will be available at port 5050 (e.g. http://localhost:5050). When deploying this setup, the pgAdmin web interface will be available at port 5050 (e.g. http://localhost:5050).
``` shell ``` shell
$ docker-compose up $ docker compose up
Starting postgres ... done Starting postgres ... done
Starting pgadmin ... done Starting pgadmin ... done
``` ```
@ -62,7 +62,7 @@ d3cde3b455ee dpage/pgadmin4:latest "/entrypoint.sh" 9 minute
Stop the containers with Stop the containers with
``` shell ``` shell
$ docker-compose down $ docker compose down
# To delete all data run: # To delete all data run:
$ docker-compose down -v $ docker compose down -v
``` ```

@ -4,7 +4,7 @@
Project structure: Project structure:
``` ```
. .
├── docker-compose.yml ├── compose.yaml
├── grafana ├── grafana
│   └── datasource.yml │   └── datasource.yml
├── prometheus ├── prometheus
@ -12,7 +12,7 @@ Project structure:
└── README.md └── README.md
``` ```
[_docker-compose.yml_](docker-compose.yml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
prometheus: prometheus:
@ -27,13 +27,13 @@ services:
- 3000:3000 - 3000:3000
``` ```
The compose file defines a stack with two services `prometheus` and `grafana`. The compose file defines a stack with two services `prometheus` and `grafana`.
When deploying the stack, docker-compose maps port the default ports for each service to the equivalent ports on the host in order to inspect easier the web interface of each service. When deploying the stack, docker compose maps port the default ports for each service to the equivalent ports on the host in order to inspect easier the web interface of each service.
Make sure the ports 9090 and 3000 on the host are not already in use. Make sure the ports 9090 and 3000 on the host are not already in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "prometheus-grafana_default" with the default driver Creating network "prometheus-grafana_default" with the default driver
Creating volume "prometheus-grafana_prom_data" with default driver Creating volume "prometheus-grafana_prom_data" with default driver
... ...
@ -61,5 +61,5 @@ Navigate to `http://localhost:9090` in your web browser to access directly the w
Stop and remove the containers. Use `-v` to remove the volumes if looking to erase all data. Stop and remove the containers. Use `-v` to remove the volumes if looking to erase all data.
``` ```
$ docker-compose down -v $ docker compose down -v
``` ```

@ -7,14 +7,14 @@ Project structure:
├── backend ├── backend
│ ├── Dockerfile │ ├── Dockerfile
│ ... │ ...
├── docker-compose.yaml ├── compose.yaml
├── frontend ├── frontend
│ ├── ... │ ├── ...
│ └── Dockerfile │ └── Dockerfile
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
frontend: frontend:
@ -42,13 +42,13 @@ services:
... ...
``` ```
The compose file defines an application with three services `frontend`, `backend` and `db`. The compose file defines an application with three services `frontend`, `backend` and `db`.
When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file. When deploying the application, docker compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.
Make sure port 3000 on the host is not already being in use. Make sure port 3000 on the host is not already being in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "react-express-mongodb_default" with the default driver Creating network "react-express-mongodb_default" with the default driver
Building frontend Building frontend
Step 1/9 : FROM node:13.13.0-stretch-slim Step 1/9 : FROM node:13.13.0-stretch-slim
@ -78,7 +78,7 @@ After the application starts, navigate to `http://localhost:3000` in your web br
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping server ... done Stopping server ... done
Stopping frontend ... done Stopping frontend ... done
Stopping mongo ... done Stopping mongo ... done

@ -9,14 +9,14 @@ Project structure:
│   ... │   ...
├── db ├── db
│   └── password.txt │   └── password.txt
├── docker-compose.yaml ├── compose.yaml
├── frontend ├── frontend
│   ├── ... │   ├── ...
│   └── Dockerfile │   └── Dockerfile
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -39,7 +39,7 @@ services:
... ...
``` ```
The compose file defines an application with three services `frontend`, `backend` and `db`. The compose file defines an application with three services `frontend`, `backend` and `db`.
When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file. When deploying the application, docker compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.
Make sure port 3000 on the host is not already being in use. Make sure port 3000 on the host is not already being in use.
> **_INFO_** > **_INFO_**
@ -47,10 +47,10 @@ Make sure port 3000 on the host is not already being in use.
> You still can use the MySQL image by uncommenting the following line in the Compose file > You still can use the MySQL image by uncommenting the following line in the Compose file
> `#image: mysql:8.0.27` > `#image: mysql:8.0.27`
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "react-express-mysql_default" with the default driver Creating network "react-express-mysql_default" with the default driver
Building backend Building backend
Step 1/16 : FROM node:10 Step 1/16 : FROM node:10
@ -87,7 +87,7 @@ $ curl localhost:80
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping react-express-mysql_frontend_1 ... done Stopping react-express-mysql_frontend_1 ... done
Stopping react-express-mysql_backend_1 ... done Stopping react-express-mysql_backend_1 ... done
Stopping react-express-mysql_db_1 ... done Stopping react-express-mysql_db_1 ... done

@ -4,12 +4,12 @@
### Local Development Features ### Local Development Features
- **Dev as close to prod as you can**. docker-compose builds a local development image that is just like production image except for the below dev-only features needed in image. Goal is to have dev env be as close to test and prod as possible while still giving all the nice tools to make you a happy dev. - **Dev as close to prod as you can**. docker compose builds a local development image that is just like production image except for the below dev-only features needed in image. Goal is to have dev env be as close to test and prod as possible while still giving all the nice tools to make you a happy dev.
- **Prevent needing node/npm on host**. Installs `node_modules` outside app root in container so local development won't run into a problem of bind-mounting over it with local source code. This means it will run `npm install` once on container build and you don't need to run npm on host or on each docker run. It will re-run on build if you change `package.json`. - **Prevent needing node/npm on host**. Installs `node_modules` outside app root in container so local development won't run into a problem of bind-mounting over it with local source code. This means it will run `npm install` once on container build and you don't need to run npm on host or on each docker run. It will re-run on build if you change `package.json`.
- **One line startup**. Uses `docker-compose up` for single-line build and run of local development server. - **One line startup**. Uses `docker-compose up` for single-line build and run of local development server.
- **Edit locally while code runs in container**. docker-compose uses proper bind-mounts of host source code into container so you can edit locally while running code in Linux container. - **Edit locally while code runs in container**. docker compose uses proper bind-mounts of host source code into container so you can edit locally while running code in Linux container.
- **Use nodemon in container**. docker-compose uses nodemon for development for auto-restarting node in container when you change files on host. - **Use nodemon in container**. docker compose uses nodemon for development for auto-restarting node in container when you change files on host.
- **Enable debug from host to container**. opens the inspect port 9229 for using host-based debugging like chrome tools or VS Code. Nodemon enables `--inspect` by default in docker-compose. - **Enable debug from host to container**. opens the inspect port 9229 for using host-based debugging like chrome tools or VS Code. Nodemon enables `--inspect` by default in docker compose.
- **Provides VSCode debug configs and tasks for tests**. for Visual Studio Code fans, `.vscode` directory has the goods, thanks to @JPLemelin. - **Provides VSCode debug configs and tasks for tests**. for Visual Studio Code fans, `.vscode` directory has the goods, thanks to @JPLemelin.
- **Small image and quick re-builds**. `COPY` in `package.json` and run `npm install` **before** `COPY` in your source code. This saves big on build time and keep container lean. - **Small image and quick re-builds**. `COPY` in `package.json` and run `npm install` **before** `COPY` in your source code. This saves big on build time and keep container lean.
- **Bind-mount package.json**. This allows adding packages in realtime without rebuilding images. e.g. `dce node npm install --save <package name>` - **Bind-mount package.json**. This allows adding packages in realtime without rebuilding images. e.g. `dce node npm install --save <package name>`
@ -18,19 +18,19 @@
### Production-minded Features ### Production-minded Features
- **Use Docker build-in healthchecks**. uses Dockerfile `HEALTHCHECK` with `/healthz` route to help Docker know if your container is running properly (example always returns 200, but you get the idea). - **Use Docker build-in healthchecks**. uses Dockerfile `HEALTHCHECK` with `/healthz` route to help Docker know if your container is running properly (example always returns 200, but you get the idea).
- **Proper NODE_ENV use**. Defaults to `NODE_ENV=production` in Dockerfile and overrides to `development` in docker-compose for local dev. - **Proper NODE_ENV use**. Defaults to `NODE_ENV=production` in Dockerfile and overrides to `development` in docker compose for local dev.
- **Don't add dev dependencies into production image**. Proper `NODE_ENV` use means dev dependencies won't be installed in container by default. Using docker-compose will build with them by default. - **Don't add dev dependencies into production image**. Proper `NODE_ENV` use means dev dependencies won't be installed in container by default. Using docker compose will build with them by default.
- **Enables proper SIGTERM/SIGINT for graceful exit**. Defaults to `node index.js` rather then npm for allowing graceful shutdown of node. npm doesn't pass SIGTERM/SIGINT properly (you can't ctrl-c when running `docker run` in foreground). To get `node index.js` to graceful exit, extra signal-catching code is needed. The `Dockerfile` and `index.js` document the options and links to known issues. - **Enables proper SIGTERM/SIGINT for graceful exit**. Defaults to `node index.js` rather then npm for allowing graceful shutdown of node. npm doesn't pass SIGTERM/SIGINT properly (you can't ctrl-c when running `docker run` in foreground). To get `node index.js` to graceful exit, extra signal-catching code is needed. The `Dockerfile` and `index.js` document the options and links to known issues.
- **Use docker-stack.yml example for Docker Swarm deployments**. - **Use docker-stack.yml example for Docker Swarm deployments**.
### Assumptions ### Assumptions
- You have Docker and Docker-Compose installed (Docker for Mac, Docker for Windows, get.docker.com and manual Compose installed for Linux). - You have Docker and docker compose installed (Docker for Mac, Docker for Windows, get.docker.com and manual Compose installed for Linux).
- You want to use Docker for local development (i.e. never need to install node/npm on host) and have dev and prod Docker images be as close as possible. - You want to use Docker for local development (i.e. never need to install node/npm on host) and have dev and prod Docker images be as close as possible.
- You don't want to loose fidelity in your dev workflow. You want a easy environment setup, using local editors, node debug/inspect, local code repo, while node server runs in a container. - You don't want to loose fidelity in your dev workflow. You want a easy environment setup, using local editors, node debug/inspect, local code repo, while node server runs in a container.
- You use `docker-compose` for local development only (docker-compose was never intended to be a production deployment tool anyway). - You use `docker-compose` for local development only (docker-compose was never intended to be a production deployment tool anyway).
- The `docker-compose.yml` is not meant for `docker stack deploy` in Docker Swarm, it's meant for happy local development. Use `docker-stack.yml` for Swarm. - The `compose.yaml` is not meant for `docker stack deploy` in Docker Swarm, it's meant for happy local development. Use `docker-stack.yml` for Swarm.
### Getting Started ### Getting Started
@ -46,7 +46,7 @@ If this was your Node.js app, to start local development you would:
- Compose should detect if you need to rebuild due to changed package.json or Dockerfile, but `docker-compose build` works for manually building. - Compose should detect if you need to rebuild due to changed package.json or Dockerfile, but `docker-compose build` works for manually building.
- Be sure to use `docker-compose down` to cleanup after your done dev'ing. - Be sure to use `docker-compose down` to cleanup after your done dev'ing.
If you wanted to add a package while docker-compose was running your app: If you wanted to add a package while docker compose was running your app:
- `docker-compose exec node npm install --save <package name>` - `docker-compose exec node npm install --save <package name>`
- This installs it inside the running container. - This installs it inside the running container.
- Nodemon will detect the change and restart. - Nodemon will detect the change and restart.

@ -2,7 +2,7 @@
"name": "node-docker-good-defaults", "name": "node-docker-good-defaults",
"private": true, "private": true,
"version": "2.0.1", "version": "2.0.1",
"description": "Node.js Hello world app using docker features for easy docker-compose local dev and solid production defaults", "description": "Node.js Hello world app using docker features for easy docker compose local dev and solid production defaults",
"author": "Bret Fisher <bret@bretfisher.com>", "author": "Bret Fisher <bret@bretfisher.com>",
"main": "src/index.js", "main": "src/index.js",
"scripts": { "scripts": {

@ -14,7 +14,7 @@ module.exports = {
: null : null
}, },
port: process.env.PORT || 8080 port: process.env.PORT || 8080
// if you're not using docker-compose for local development, this will default to 8080 // if you're not using docker compose for local development, this will default to 8080
// to prevent non-root permission problems with 80. Dockerfile is set to make this 80 // to prevent non-root permission problems with 80. Dockerfile is set to make this 80
// because containers don't have that issue :) // because containers don't have that issue :)
}; };

@ -9,14 +9,14 @@ Project structure:
│   ... │   ...
├── db ├── db
│   └── password.txt │   └── password.txt
├── docker-compose.yaml ├── compose.yaml
├── frontend ├── frontend
│   ├── ... │   ├── ...
│   └── Dockerfile │   └── Dockerfile
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -35,7 +35,7 @@ services:
... ...
``` ```
The compose file defines an application with three services `frontend`, `backend` and `db`. The compose file defines an application with three services `frontend`, `backend` and `db`.
When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file. When deploying the application, docker compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.
Make sure port 3000 on the host is not already being in use. Make sure port 3000 on the host is not already being in use.
> **_INFO_** > **_INFO_**
@ -43,10 +43,10 @@ Make sure port 3000 on the host is not already being in use.
> You still can use the MySQL image by uncommenting the following line in the Compose file > You still can use the MySQL image by uncommenting the following line in the Compose file
> `#image: mysql:8.0.27` > `#image: mysql:8.0.27`
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "react-java-mysql_default" with the default driver Creating network "react-java-mysql_default" with the default driver
Building backend Building backend
Step 1/17 : FROM maven:3.6.3-jdk-11 AS builder Step 1/17 : FROM maven:3.6.3-jdk-11 AS builder
@ -74,7 +74,7 @@ After the application starts, navigate to `http://localhost:3000` in your web br
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping react-java-mysql_backend_1 ... done Stopping react-java-mysql_backend_1 ... done
Stopping react-java-mysql_frontend_1 ... done Stopping react-java-mysql_frontend_1 ... done
Stopping react-java-mysql_db_1 ... done Stopping react-java-mysql_db_1 ... done

@ -5,7 +5,7 @@
Project structure: Project structure:
``` ```
├── docker-compose.yml ├── compose.yaml
├── Dockerfile ├── Dockerfile
├── .dockerignore ├── .dockerignore
├── .nginx ├── .nginx
@ -22,7 +22,7 @@ Project structure:
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
@ -35,12 +35,12 @@ services:
``` ```
The compose file defines an application with an services `frontend`. The compose file defines an application with an services `frontend`.
When deploying the application, docker-compose maps port 80 of the frontend service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 80 of the frontend service container to port 80 of the host as specified in the file.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Building frontend Building frontend
Sending build context to Docker daemon 1.49MB Sending build context to Docker daemon 1.49MB
@ -81,7 +81,7 @@ After the application start, navigate to http://localhost in your browser:
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping frontend ... done Stopping frontend ... done
Removing frontend ... done Removing frontend ... done
Removing network react-nginx_default Removing network react-nginx_default

@ -8,14 +8,14 @@ Project structure:
├── backend ├── backend
│   ├── Dockerfile │   ├── Dockerfile
│   ... │   ...
├── docker-compose.yaml ├── compose.yaml
├── frontend ├── frontend
│   ├── ... │   ├── ...
│   └── Dockerfile │   └── Dockerfile
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -31,13 +31,13 @@ services:
... ...
``` ```
The compose file defines an application with three services `frontend`, `backend` and `db`. The compose file defines an application with three services `frontend`, `backend` and `db`.
When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file. When deploying the application, docker compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.
Make sure port 3000 on the host is not already being in use. Make sure port 3000 on the host is not already being in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "react-rust-postgres_default" with the default driver Creating network "react-rust-postgres_default" with the default driver
Building backend Building backend
... ...
@ -65,7 +65,7 @@ After the application starts, navigate to `http://localhost:3000` in your web br
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping react-rust-postgres_backend_1 ... done Stopping react-rust-postgres_backend_1 ... done
Stopping react-rust-postgres_frontend_1 ... done Stopping react-rust-postgres_frontend_1 ... done
Stopping react-rust-postgres_db_1 ... done Stopping react-rust-postgres_db_1 ... done

@ -9,12 +9,12 @@ Project structure:
│   └── ... │   └── ...
├── db ├── db
│   └── password.txt │   └── password.txt
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -29,7 +29,7 @@ services:
... ...
``` ```
The compose file defines an application with two services `backend` and `db`. The compose file defines an application with two services `backend` and `db`.
When deploying the application, docker-compose maps port 8080 of the backend service container to port 80 of the host as specified in the file. When deploying the application, docker compose maps port 8080 of the backend service container to port 80 of the host as specified in the file.
Make sure port 8080 on the host is not already being in use. Make sure port 8080 on the host is not already being in use.
> **_INFO_** > **_INFO_**
@ -37,10 +37,10 @@ Make sure port 8080 on the host is not already being in use.
> You still can use the MySQL image by uncommenting the following line in the Compose file > You still can use the MySQL image by uncommenting the following line in the Compose file
> `#image: mysql:8.0.27` > `#image: mysql:8.0.27`
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "sparkjava-mysql_default" with the default driver Creating network "sparkjava-mysql_default" with the default driver
Building backend Building backend
... ...
@ -68,7 +68,7 @@ $ curl localhost:8080
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping sparkjava-mysql_backend_1 ... done Stopping sparkjava-mysql_backend_1 ... done
Stopping sparkjava-mysql_db_1 ... done Stopping sparkjava-mysql_db_1 ... done
Removing sparkjava-mysql_backend_1 ... done Removing sparkjava-mysql_backend_1 ... done

@ -4,14 +4,14 @@
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
├── README.md ├── README.md
└── sparkjava └── sparkjava
├── Dockerfile ├── Dockerfile
└── ... └── ...
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
sparkjava: sparkjava:
@ -20,13 +20,13 @@ services:
- 8080:8080 - 8080:8080
``` ```
The compose file defines an application with one service `sparkjava`. The compose file defines an application with one service `sparkjava`.
When deploying the application, docker-compose maps port 8080 of the sparkjava service container to port 8080 of the host as specified in the file. When deploying the application, docker compose maps port 8080 of the sparkjava service container to port 8080 of the host as specified in the file.
Make sure port 8080 on the host is not already being in use. Make sure port 8080 on the host is not already being in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "sparkjava_default" with the default driver Creating network "sparkjava_default" with the default driver
Building sparkjava Building sparkjava
Step 1/11 : FROM maven:3.6.3-jdk-11 AS build Step 1/11 : FROM maven:3.6.3-jdk-11 AS build
@ -54,7 +54,7 @@ Hello from Docker!
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping sparkjava_sparkjava_1 ... done Stopping sparkjava_sparkjava_1 ... done
Removing sparkjava_sparkjava_1 ... done Removing sparkjava_sparkjava_1 ... done
Removing network sparkjava_default Removing network sparkjava_default

@ -9,12 +9,12 @@ Project structure:
│   └── ... │   └── ...
├── db ├── db
│   └── password.txt │   └── password.txt
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
backend: backend:
@ -26,13 +26,13 @@ services:
... ...
``` ```
The compose file defines an application with two services `backend` and `db`. The compose file defines an application with two services `backend` and `db`.
When deploying the application, docker-compose maps port 8080 of the backend service container to port 8080 of the host as specified in the file. When deploying the application, docker compose maps port 8080 of the backend service container to port 8080 of the host as specified in the file.
Make sure port 8080 on the host is not already being in use. Make sure port 8080 on the host is not already being in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "spring-postgres_default" with the default driver Creating network "spring-postgres_default" with the default driver
Building backend Building backend
Step 1/11 : FROM maven:3.5-jdk-9 AS build Step 1/11 : FROM maven:3.5-jdk-9 AS build
@ -70,7 +70,7 @@ $ curl localhost:8080
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping spring-postgres_db_1 ... done Stopping spring-postgres_db_1 ... done
Stopping spring-postgres_backend_1 ... done Stopping spring-postgres_backend_1 ... done
Removing spring-postgres_db_1 ... done Removing spring-postgres_db_1 ... done

@ -7,11 +7,11 @@ Project structure:
├── backend ├── backend
│   ├── Dockerfile │   ├── Dockerfile
│   └── main.go │   └── main.go
├── docker-compose.yml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
frontend: frontend:
@ -34,13 +34,13 @@ services:
``` ```
The compose file defines an application with two services `frontend` and `backend`. The compose file defines an application with two services `frontend` and `backend`.
When deploying the application, docker-compose maps port 80 of the frontend service container to the same port of the host as specified in the file. When deploying the application, docker compose maps port 80 of the frontend service container to the same port of the host as specified in the file.
Make sure port 80 on the host is not already being in use. Make sure port 80 on the host is not already being in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "traefik-golang_default" with the default driver Creating network "traefik-golang_default" with the default driver
Building backend Building backend
Step 1/7 : FROM golang:1.13 AS build Step 1/7 : FROM golang:1.13 AS build
@ -92,5 +92,5 @@ Hello from Docker!
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```

@ -4,14 +4,14 @@
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
├── README.md ├── README.md
└── vuejs └── vuejs
├── Dockerfile ├── Dockerfile
└── ... └── ...
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
web: web:
@ -23,13 +23,13 @@ services:
- /project/node_modules - /project/node_modules
``` ```
The compose file defines an application with one service `vuejs`. The compose file defines an application with one service `vuejs`.
When deploying the application, docker-compose maps port 8080 of the web service container to port 8080 of the host as specified in the file. When deploying the application, docker compose maps port 8080 of the web service container to port 8080 of the host as specified in the file.
Make sure port 8080 on the host is not already being in use. Make sure port 8080 on the host is not already being in use.
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "vuejs_default" with the default driver Creating network "vuejs_default" with the default driver
Building web Building web
Step 1/8 : FROM node:13.10.1-alpine Step 1/8 : FROM node:13.10.1-alpine
@ -54,7 +54,7 @@ After the application starts, navigate to `http://localhost:80` in your web brow
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
Stopping vuejs_web_1 ... done Stopping vuejs_web_1 ... done
Removing vuejs_web_1 ... done Removing vuejs_web_1 ... done
Removing network vuejs_default Removing network vuejs_default

@ -6,11 +6,11 @@ Project structure:
``` ```
. .
├── .env ├── .env
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` yaml ``` yaml
services: services:
wireguard: wireguard:
@ -24,11 +24,11 @@ Before deploying this setup, you need to configure the following values in the [
- TIMEZONE - TIMEZONE
- VPN_SERVER_URL (recommended setting up a server url with e.g. http://www.duckdns.org/ if you don't own a domain) - VPN_SERVER_URL (recommended setting up a server url with e.g. http://www.duckdns.org/ if you don't own a domain)
## Deploy with docker-compose ## Deploy with docker compose
When deploying this setup, the log will show relevant information. You need to forward the external port 51820 to access your VPN from outside. When deploying this setup, the log will show relevant information. You need to forward the external port 51820 to access your VPN from outside.
``` shell ``` shell
$ docker-compose up $ docker compose up
Starting wireguard ... Starting wireguard ...
wireguard | **** It seems the wireguard module is already active. Skipping kernel header install and module compilation. **** wireguard | **** It seems the wireguard module is already active. Skipping kernel header install and module compilation. ****
wireguard | **** Server mode is selected **** wireguard | **** Server mode is selected ****
@ -63,9 +63,9 @@ Install your Wireguard client on an Apple device by downloading the wireguard ap
Stop the containers with Stop the containers with
``` shell ``` shell
$ docker-compose down $ docker compose down
# To delete all data run: # To delete all data run:
$ docker-compose down -v $ docker compose down -v
``` ```
## Troubleshooting ## Troubleshooting

@ -5,11 +5,11 @@ This example defines one of the basic setups for WordPress. More details on how
Project structure: Project structure:
``` ```
. .
├── docker-compose.yaml ├── compose.yaml
└── README.md └── README.md
``` ```
[_docker-compose.yaml_](docker-compose.yaml) [_compose.yaml_](compose.yaml)
``` ```
services: services:
db: db:
@ -26,7 +26,7 @@ services:
... ...
``` ```
When deploying this setup, docker-compose maps the WordPress container port 80 to When deploying this setup, docker compose maps the WordPress container port 80 to
port 80 of the host as specified in the compose file. port 80 of the host as specified in the compose file.
> **_INFO_** > **_INFO_**
@ -34,10 +34,10 @@ port 80 of the host as specified in the compose file.
> You still can use the MySQL image by uncommenting the following line in the Compose file > You still can use the MySQL image by uncommenting the following line in the Compose file
> `#image: mysql:8.0.27` > `#image: mysql:8.0.27`
## Deploy with docker-compose ## Deploy with docker compose
``` ```
$ docker-compose up -d $ docker compose up -d
Creating network "wordpress-mysql_default" with the default driver Creating network "wordpress-mysql_default" with the default driver
Creating volume "wordpress-mysql_db_data" with default driver Creating volume "wordpress-mysql_db_data" with default driver
... ...
@ -63,10 +63,10 @@ Navigate to `http://localhost:80` in your web browser to access WordPress.
Stop and remove the containers Stop and remove the containers
``` ```
$ docker-compose down $ docker compose down
``` ```
To remove all WordPress data, delete the named volumes by passing the `-v` parameter: To remove all WordPress data, delete the named volumes by passing the `-v` parameter:
``` ```
$ docker-compose down -v $ docker compose down -v
``` ```

Loading…
Cancel
Save