diff --git a/README.md b/README.md index a65f2fc..a310ce3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ These samples provide a starting point for how to integrate different services u > The following samples are intended for use in local development environments such as project setups, tinkering with software stacks, etc. These samples must not be deployed in production environments. + ## Contents - [Samples of Docker Compose applications with multiple integrated services](#samples-of-docker-compose-applications-with-multiple-integrated-services). @@ -21,17 +22,17 @@ These samples provide a starting point for how to integrate different services u Use with Docker Dev Environments Icon indicates Sample is compatible with [Docker Dev Environments](https://docs.docker.com/desktop/dev-environments/) in Docker Desktop version 4.10 or later. - [`ASP.NET / MS-SQL`](aspnet-mssql) - Sample ASP.NET core application -with MS SQL server database. + with MS SQL server database. - [`Elasticsearch / Logstash / Kibana`](elasticsearch-logstash-kibana) - Sample Elasticsearch, Logstash, and Kibana stack. - [`Go / NGINX / MySQL`](nginx-golang-mysql) - Sample Go application -with an Nginx proxy and a MySQL database. Use with Docker Dev Environments + with an Nginx proxy and a MySQL database. Use with Docker Dev Environments - [`Go / NGINX / PostgreSQL`](nginx-golang-postgres) - Sample Go -application with an Nginx proxy and a PostgreSQL database. Use with Docker Dev Environments + application with an Nginx proxy and a PostgreSQL database. Use with Docker Dev Environments - [`Java Spark / MySQL`](sparkjava-mysql) - Sample Java application and -a MySQL database. Use with Docker Dev Environments + a MySQL database. Use with Docker Dev Environments - [`NGINX / ASP.NET / MySQL`](nginx-aspnet-mysql) - Sample Nginx reverse proxy with an C# backend using ASP.NET Use with Docker Dev Environments - [`NGINX / Flask / MongoDB`](nginx-flask-mongo) - Sample Python/Flask -application with Nginx proxy and a Mongo database. Use with Docker Dev Environments + application with Nginx proxy and a Mongo database. Use with Docker Dev Environments - [`NGINX / Flask / MySQL`](nginx-flask-mysql) - Sample Python/Flask application with an Nginx proxy and a MySQL database. - [`NGINX / Node.js / Redis`](nginx-nodejs-redis) - Sample Node.js application with Nginx proxy and a Redis database - [`NGINX / Go`](nginx-golang) - Sample Nginx proxy with a Go backend. Use with Docker Dev Environments @@ -39,16 +40,16 @@ application with Nginx proxy and a Mongo database. Use with Docker Dev Environments - [`React / Spring / MySQL`](react-java-mysql) - Sample React -application with a Spring backend and a MySQL database. Use with Docker Dev Environments + application with a Spring backend and a MySQL database. Use with Docker Dev Environments - [`React / Express / MySQL`](react-express-mysql) - Sample React -application with a Node.js backend and a MySQL database. Use with Docker Dev Environments + application with a Node.js backend and a MySQL database. Use with Docker Dev Environments - [`React / Express / MongoDB`](react-express-mongodb) - Sample React -application with a Node.js backend and a Mongo database. Use with Docker Dev Environments + application with a Node.js backend and a Mongo database. Use with Docker Dev Environments - [`React / Rust / PostgreSQL`](react-rust-postgres) - Sample React -application with a Rust backend and a Postgres database. Use with Docker Dev Environments + application with a Rust backend and a Postgres database. Use with Docker Dev Environments - [`React / Nginx`](react-nginx) - Sample React application with Nginx. Use with Docker Dev Environments - [`Spring / PostgreSQL`](spring-postgres) - Sample Java application -with Spring framework and a Postgres database. Use with Docker Dev Environments + with Spring framework and a Postgres database. Use with Docker Dev Environments ## Single service samples @@ -99,7 +100,7 @@ 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: ```console -docker compose up -d +docker-compose up -d ``` Check the `README.md` of each sample to get more details on the structure and @@ -107,7 +108,7 @@ what is the expected output. To stop and remove all containers of the sample application run: ```console -docker compose down +docker-compose down ``` ### Quickstart guides @@ -115,7 +116,8 @@ docker compose down In addition to all the ready to run Compose samples listed above the folder [official-documentation-samples](official-documentation-samples/README.md) contains quickstart guides. Each of these step by step guides explain which files need to be created to build and run a Docker Compose application. + ## Contribute We welcome examples that help people understand how to use Docker Compose for -common applications. Check the [Contribution Guide](CONTRIBUTING.md) for more details. +common applications. Check the [Contribution Guide](CONTRIBUTING.md) for more details. diff --git a/angular/README.md b/angular/README.md index 6d164a6..9f3724d 100644 --- a/angular/README.md +++ b/angular/README.md @@ -1,4 +1,4 @@ -## Compose sample +## Compose sample ### Use with Docker Development Environments @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Angular service Project structure: + ``` . ├── angular @@ -20,6 +21,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: web: @@ -29,16 +31,16 @@ 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). 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. - ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "angular_default" with the default driver Building angular Step 1/7 : FROM node:10 @@ -52,10 +54,10 @@ WARNING: Image for service web was built because it did not already exist. To re Creating angular_web_1 ... done ``` - ## Expected result Listing containers must show a container running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -70,5 +72,5 @@ After the application starts, navigate to `http://localhost:4200` in your web br Stop and remove the container ``` -$ docker compose down +$ docker-compose down ``` diff --git a/apache-php/README.md b/apache-php/README.md index 7179b8f..833c427 100644 --- a/apache-php/README.md +++ b/apache-php/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### PHP application with Apache2 Project structure: + ``` . ├── compose.yaml @@ -19,11 +20,12 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: web: build: app - ports: + ports: - '80:80' volumes: - ./app:/var/www/html/ @@ -32,7 +34,7 @@ services: ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "php-docker_web" with the default driver Building web Step 1/6 : FROM php:7.2-apache @@ -45,6 +47,7 @@ Creating php-docker_web_1 ... done ## Expected result Listing containers must show one container running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -52,12 +55,14 @@ CONTAINER ID IMAGE COMMAND CREATE ``` After the application starts, navigate to `http://localhost:80` in your web browser or run: + ``` $ curl localhost:80 Hello World! ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/aspnet-mssql/README.md b/aspnet-mssql/README.md index 59b1a10..8ea9924 100644 --- a/aspnet-mssql/README.md +++ b/aspnet-mssql/README.md @@ -1,6 +1,7 @@ ## Compose sample application: ASP.NET with MS SQL server database Project structure: + ``` . ├── app @@ -13,6 +14,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: web: @@ -26,6 +28,7 @@ services: #image: mcr.microsoft.com/mssql/server ... ``` + 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. @@ -33,13 +36,13 @@ Make sure port 80 on the host is not being used by another container, otherwise > ℹ️ **_INFO_** > For compatibility purpose between `AMD64` and `ARM64` architecture, we use Azure SQL Edge as database instead of MS SQL Server. -> 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` ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "aspnet-mssql_default" with the default driver Building web Step 1/13 : FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build @@ -53,10 +56,10 @@ Creating aspnet-mssql_web_1 ... done Creating aspnet-mssql_db_1 ... done ``` - ## Expected result Listing containers must show two containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -71,5 +74,5 @@ After the application starts, navigate to `http://localhost:80` in your web brow Stop and remove the containers ``` -$ docker compose down +$ docker-compose down ``` diff --git a/django/README.md b/django/README.md index 53c97f5..35e8dbb 100644 --- a/django/README.md +++ b/django/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Django application in dev mode Project structure: + ``` . ├── compose.yaml @@ -20,18 +21,19 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` -services: - web: - build: app - ports: +services: + web: + build: app + ports: - '8000:8000' ``` ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "django_default" with the default driver Building web Step 1/6 : FROM python:3.7-alpine @@ -45,6 +47,7 @@ Creating django_web_1 ... done ## Expected result Listing containers must show one container running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -54,6 +57,7 @@ CONTAINER ID IMAGE COMMAND CREATED After the application starts, navigate to `http://localhost:8000` in your web browser: Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/elasticsearch-logstash-kibana/README.md b/elasticsearch-logstash-kibana/README.md index 9527d05..c2c26ab 100644 --- a/elasticsearch-logstash-kibana/README.md +++ b/elasticsearch-logstash-kibana/README.md @@ -1,13 +1,16 @@ ## Compose sample application + ### Elasticsearch, Logstash, and Kibana (ELK) in single-node Project structure: + ``` . └── compose.yaml ``` [_compose.yaml_](compose.yaml) + ``` services: elasticsearch: @@ -24,7 +27,7 @@ services: ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "elasticsearch-logstash-kibana_elastic" with driver "bridge" Creating es ... done Creating log ... done @@ -34,6 +37,7 @@ Creating kib ... done ## Expected result Listing containers must show three containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -44,13 +48,14 @@ b448fd3e9b30 kibana:7.8.0 "/usr/local/bin/dumb…" 43 seconds After the application starts, navigate to below links in your web browser: -* Elasticsearch: [`http://localhost:9200`](http://localhost:9200) -* Logstash: [`http://localhost:9600`](http://localhost:9600) -* Kibana: [`http://localhost:5601/api/status`](http://localhost:5601/api/status) +- Elasticsearch: [`http://localhost:9200`](http://localhost:9200) +- Logstash: [`http://localhost:9600`](http://localhost:9600) +- Kibana: [`http://localhost:5601/api/status`](http://localhost:5601/api/status) Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` ## Attribution diff --git a/fastapi/README.md b/fastapi/README.md index 13434de..d63b8ef 100644 --- a/fastapi/README.md +++ b/fastapi/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Python/FastAPI application Project structure: + ``` ├── compose.yaml ├── Dockerfile @@ -20,6 +21,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: api: @@ -38,9 +40,11 @@ services: ```shell docker-compose up -d --build ``` + ## Expected result Listing containers must show one container running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -48,6 +52,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS ``` After the application starts, navigate to `http://localhost:8000` in your web browser and you should see the following json response: + ``` { "message": "OK" @@ -55,6 +60,7 @@ After the application starts, navigate to `http://localhost:8000` in your web br ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/flask-redis/README.md b/flask-redis/README.md index f9dfd03..f6aba28 100644 --- a/flask-redis/README.md +++ b/flask-redis/README.md @@ -23,10 +23,10 @@ Project structure: ``` services: - redis: + redis: image: redislabs/redismod ports: - - '6379:6379' + - '6379:6379' web: build: . ports: @@ -40,31 +40,33 @@ services: ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d [+] Running 24/24 - ⠿ redis Pulled - ... - ⠿ 565225d89260 Pull complete + ⠿ redis Pulled + ... + ⠿ 565225d89260 Pull complete [+] Building 12.7s (10/10) FINISHED => [internal] load build definition from Dockerfile ... [+] Running 3/3 - ⠿ Network flask-redis_default Created - ⠿ Container flask-redis-redis-1 Started + ⠿ Network flask-redis_default Created + ⠿ Container flask-redis-redis-1 Started ⠿ Container flask-redis-web-1 Started ``` ## Expected result Listing containers must show one container running and the port mapping as below: + ``` -$ docker compose ps +$ docker-compose ps NAME COMMAND SERVICE STATUS PORTS 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:8000->8000/tcp ``` After the application starts, navigate to `http://localhost:8000` in your web browser or run: + ``` $ curl localhost:8000 This webpage has been viewed 2 time(s) @@ -72,7 +74,8 @@ This webpage has been viewed 2 time(s) ## Monitoring Redis keys -Connect to redis database by using ```redis-cli``` command and monitor the keys. +Connect to redis database by using `redis-cli` command and monitor the keys. + ``` redis-cli -p 6379 127.0.0.1:6379> monitor @@ -81,8 +84,8 @@ OK 1646634062.735669 [0 172.21.0.3:33106] "GET" "hits" ``` - Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/flask/README.md b/flask/README.md index c8b0efd..87fbf60 100644 --- a/flask/README.md +++ b/flask/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Python/Flask application Project structure: + ``` . ├── compose.yaml @@ -20,20 +21,21 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` -services: - web: +services: + web: build: context: app target: builder - ports: + ports: - '8000:8000' ``` ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d [+] Building 1.1s (16/16) FINISHED => [internal] load build definition from Dockerfile 0.0s ... 0.0s @@ -46,19 +48,22 @@ $ docker compose up -d ## Expected result Listing containers must show one container running and the port mapping as below: + ``` -$ docker compose ps +$ docker-compose ps NAME COMMAND SERVICE STATUS PORTS flask-web-1 "python3 app.py" web running 0.0.0.0:8000->8000/tcp ``` After the application starts, navigate to `http://localhost:8000` in your web browser or run: + ``` $ curl localhost:8000 Hello World! ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/gitea-postgres/README.md b/gitea-postgres/README.md index 7fba2b7..cd43ed4 100644 --- a/gitea-postgres/README.md +++ b/gitea-postgres/README.md @@ -1,8 +1,9 @@ ## Gitea with PostgreSQL + This example defines one of the base setups for Gitea. More details on how to customize the installation and the compose file can be found in [Gitea documentation](https://docs.gitea.io/en-us/install-with-docker/). - Project structure: + ``` . ├── compose.yaml @@ -10,6 +11,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: gitea: @@ -29,7 +31,7 @@ the same port of the host as specified in the compose file. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "gitea-postgres_default" with the default driver Creating gitea-postgres_db_1 ... done Creating gitea-postgres_gitea_1 ... done @@ -39,10 +41,10 @@ Starting gitea-postgres_db_1 ... done Starting gitea-postgres_gitea_1 ... done ``` - ## Expected result Check containers are running and the port mapping: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -58,10 +60,11 @@ Gitea service. 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: + ``` -$ docker compose down -v +$ docker-compose down -v ``` diff --git a/minecraft/README.md b/minecraft/README.md index 07c8dfd..729ebff 100644 --- a/minecraft/README.md +++ b/minecraft/README.md @@ -1,7 +1,9 @@ ## Minecraft server + This example defines a basic setup for a Minecraft server. More details on the Minecraft server docker image can be found [here](https://github.com/itzg/docker-minecraft-server/blob/master/README.md). Project structure: + ``` . ├── compose.yaml @@ -9,6 +11,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: minecraft: @@ -28,13 +31,13 @@ This example maps the Minecraft data folder holding all game storage to ~/minecr ``` $ 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. Creating network "minecraft_default" with the default driver Creating minecraft_minecraft_1 ... done ``` -Note: this is using a volume in order to store Minecraft server data, that can be recovered if you remove the container and restart it. +Note: this is using a volume in order to store Minecraft server data, that can be recovered if you remove the container and restart it. ## Expected result @@ -49,7 +52,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: ``` -$ 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-7/INFO]: Preparing spawn area: 94% @@ -63,20 +66,20 @@ minecraft_1 | [15:06:39] [RCON Listener #1/INFO]: RCON running on 0.0.0.0:25575 Once it is initialized, run your Minecraft application, hit "Play", then "Multiplayer" and "Add server" ![add server](screenshots/click-add-server.png) - Specify your new server IP : localhost:25565 - ![server configuration](screenshots/add-server-config.png) +Specify your new server IP : localhost:25565 +![server configuration](screenshots/add-server-config.png) - You can then start playing - ![ready to play](screenshots/ready-to-play.png) +You can then start playing +![ready to play](screenshots/ready-to-play.png) Stop and remove the containers ``` -$ docker compose down +$ docker-compose down ``` To delete all data, remove all named volumes by passing the -v arguments: ``` -$ docker compose down -v -``` \ No newline at end of file +$ docker-compose down -v +``` diff --git a/nextcloud-postgres/README.md b/nextcloud-postgres/README.md index b0be42a..306c837 100644 --- a/nextcloud-postgres/README.md +++ b/nextcloud-postgres/README.md @@ -1,10 +1,11 @@ ## Nextcloud with Postgres database + This example defines one of the base setups for Nextcloud. More details on how to further customize the installation and the compose file can be found on the [official image page](https://hub.docker.com/_/nextcloud). - Project structure: + ``` . ├── compose.yaml @@ -12,6 +13,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: nc: @@ -30,7 +32,7 @@ port 80 of the host as specified in the compose file. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "nextcloud-postgres_default" with the default driver Creating volume "nextcloud-postgres_nc_data" with default driver Pulling nc (nextcloud:apache)... @@ -41,10 +43,10 @@ Creating nextcloud-postgres_nc_1 ... done Creating nextcloud-postgres_db_1 ... done ``` - ## Expected result Check containers are running and the port mapping: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -60,5 +62,5 @@ Nextcloud service. Stop and remove the containers ``` -$ docker compose down +$ docker-compose down ``` diff --git a/nextcloud-redis-mariadb/README.md b/nextcloud-redis-mariadb/README.md index 8f4b133..69288e4 100644 --- a/nextcloud-redis-mariadb/README.md +++ b/nextcloud-redis-mariadb/README.md @@ -1,10 +1,11 @@ ## Nextcloud with Redis and MariaDB + This example defines one of the basic setups for Nextcloud. More details on how to further customize the installation and the compose file can be found on the [official image page](https://hub.docker.com/_/nextcloud). - Project structure: + ``` . ├── compose.yaml @@ -12,6 +13,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: nc: @@ -35,7 +37,7 @@ port 80 of the host as specified in the compose file. ## 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_dbnet" with the default driver Creating volume "nextcloud-redis-mariadb_nc_data" with default driver @@ -48,10 +50,10 @@ Creating nextcloud-redis-mariadb_nc_1 ... done Creating nextcloud-redis-mariadb_redis_1 ... done ``` - ## Expected result Check containers are running and the port mapping: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -68,10 +70,11 @@ Nextcloud service. Stop and remove the containers ``` -$ docker compose down +$ docker-compose down ``` To delete all data, remove all named volumes by passing the `-v` arguments: + ``` -$ docker compose down -v +$ docker-compose down -v ``` diff --git a/nginx-aspnet-mysql/README.md b/nginx-aspnet-mysql/README.md index e18863c..658064c 100644 --- a/nginx-aspnet-mysql/README.md +++ b/nginx-aspnet-mysql/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### ASP.NET server with an Nginx proxy and a MySQL database Project structure: + ``` . ├── backend @@ -25,6 +26,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: backend: @@ -43,24 +45,26 @@ services: - 80:80 ... ``` + 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. Make sure port 80 on the host is not already being in use. > ℹ️ **_INFO_** > For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL. -> 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` ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d ``` ## Expected result Listing containers must show three containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -73,12 +77,14 @@ l_db_1 ``` After the application starts, navigate to `http://localhost:80` in your web browser or run: + ``` $ curl localhost:80 ["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"] ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/nginx-flask-mongo/README.md b/nginx-flask-mongo/README.md index 97fa9ff..c1363dd 100644 --- a/nginx-flask-mongo/README.md +++ b/nginx-flask-mongo/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Python/Flask application with Nginx proxy and a Mongo database Project structure: + ``` . ├── compose.yaml @@ -22,6 +23,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: web: @@ -34,6 +36,7 @@ services: mongo: image: mongo ``` + 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. Make sure port 80 on the host is not being used by another container, otherwise the port should be changed. @@ -41,7 +44,7 @@ Make sure port 80 on the host is not being used by another container, otherwise ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "nginx-flask-mongo_default" with the default driver Pulling mongo (mongo:)... latest: Pulling from library/mongo @@ -58,6 +61,7 @@ Creating nginx-flask-mongo_web_1 ... done ## Expected result Listing containers must show three containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -67,12 +71,14 @@ d7eea5481c77 mongo "docker-entrypoint.s…" About ``` After the application starts, navigate to `http://localhost:80` in your web browser or run: + ``` $ curl localhost:80 Hello from the MongoDB client! ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/nginx-flask-mysql/README.md b/nginx-flask-mysql/README.md index 291612c..cf3f498 100644 --- a/nginx-flask-mysql/README.md +++ b/nginx-flask-mysql/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Python/Flask with Nginx proxy and MySQL database Project structure: + ``` . ├── compose.yaml @@ -22,6 +23,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: backend: @@ -39,19 +41,20 @@ services: build: proxy ... ``` + 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. Make sure port 80 on the host is not already being in use. > ℹ️ **_INFO_** > For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL. -> 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` ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "nginx-flask-mysql_default" with the default driver Pulling db (mysql:8.0.19)... 5.7: Pulling from library/mysql @@ -66,8 +69,9 @@ Creating nginx-flask-mysql_proxy_1 ... done ## Expected result Listing containers should show three containers running and the port mapping as below: + ``` -$ docker compose ps +$ docker-compose ps NAME COMMAND SERVICE STATUS PORTS nginx-flask-mysql-backend-1 "flask run" backend running 0.0.0.0:8000->8000/tcp nginx-flask-mysql-db-1 "docker-entrypoint.s…" db running (healthy) 3306/tcp, 33060/tcp @@ -75,12 +79,14 @@ nginx-flask-mysql-proxy-1 "nginx -g 'daemon of…" proxy run ``` After the application starts, navigate to `http://localhost:80` in your web browser or run: + ``` $ curl localhost:80
Blog post #1
Blog post #2
Blog post #3
Blog post #4
``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/nginx-golang-mysql/README.md b/nginx-golang-mysql/README.md index 1696a85..cbc8026 100644 --- a/nginx-golang-mysql/README.md +++ b/nginx-golang-mysql/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Go server with an Nginx proxy and a MariaDB/MySQL database Project structure: + ``` . ├── backend @@ -25,6 +26,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ```yaml services: backend: @@ -49,19 +51,20 @@ services: - 80:80 ... ``` + 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. Make sure port 80 on the host is not already being in use. > ℹ️ **_INFO_** > For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL. -> 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` ## Deploy with docker compose ```shell -$ docker compose up -d +$ docker-compose up -d Creating network "nginx-golang-mysql_default" with the default driver Building backend Step 1/8 : FROM golang:1.13-alpine AS build @@ -78,8 +81,9 @@ Creating nginx-golang-mysql_proxy_1 ... done ## Expected result Listing containers must show three containers running and the port mapping as below: + ```shell -$ docker compose ps +$ docker-compose ps NAME COMMAND SERVICE STATUS PORTS nginx-golang-mysql-backend-1 "/code/bin/backend" backend running nginx-golang-mysql-db-1 "docker-entrypoint.s…" db running (healthy) 3306/tcp @@ -88,12 +92,14 @@ l_db_1 ``` After the application starts, navigate to `http://localhost:80` in your web browser or run: + ```shell $ curl localhost:80 ["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"] ``` Stop and remove the containers + ```shell -$ docker compose down +$ docker-compose down ``` diff --git a/nginx-golang-postgres/README.md b/nginx-golang-postgres/README.md index 1671ec8..89164af 100644 --- a/nginx-golang-postgres/README.md +++ b/nginx-golang-postgres/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Go server with an Nginx proxy and a Postgres database Project structure: + ``` . ├── backend @@ -25,6 +26,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ```shell services: backend: @@ -46,6 +48,7 @@ services: - 80:80 ... ``` + 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. Make sure port 80 on the host is not already being in use. @@ -53,7 +56,7 @@ Make sure port 80 on the host is not already being in use. ## Deploy with docker compose ```shell -$ docker compose up -d +$ docker-compose up -d Creating network "nginx-golang-postgres_default" with the default driver Pulling db (postgres:)... latest: Pulling from library/postgres @@ -69,8 +72,9 @@ Creating nginx-golang-postgres_proxy_1 ... done ## Expected result Listing containers must show three containers running and the port mapping as below: + ```shell -$ docker compose ps +$ docker-compose ps NAME COMMAND SERVICE STATUS PORTS nginx-golang-postgres-backend-1 "/code/bin/backend" backend running nginx-golang-postgres-db-1 "docker-entrypoint.s…" db running (healthy) 5432/tcp @@ -78,12 +82,14 @@ nginx-golang-postgres-proxy-1 "/docker-entrypoint.…" proxy ``` After the application starts, navigate to `http://localhost:80` in your web browser or run: + ```shell $ curl localhost:80 ["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"] ``` Stop and remove the containers + ```shell -$ docker compose down +$ docker-compose down ``` diff --git a/nginx-golang/README.md b/nginx-golang/README.md index 506626b..758e459 100644 --- a/nginx-golang/README.md +++ b/nginx-golang/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### NGINX proxy with Go backend Project structure: + ``` . ├── backend @@ -21,6 +22,7 @@ Project structure: ``` [`compose.yaml`](compose.yaml) + ``` services: proxy: @@ -40,6 +42,7 @@ services: context: backend target: builder ``` + The compose file defines an application with two services `proxy` 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. Make sure port 80 on the host is not already in use. @@ -47,7 +50,7 @@ Make sure port 80 on the host is not already in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "nginx-golang_default" with the default driver Building backend Step 1/7 : FROM golang:1.13 AS build @@ -62,14 +65,16 @@ Creating nginx-golang_proxy_1 ... done ## Expected result Listing containers must show two containers running and the port mapping as below: + ``` -$ docker compose ps +$ docker-compose ps NAME COMMAND SERVICE STATUS PORTS nginx-golang-backend-1 "/code/bin/backend" backend running nginx-golang-proxy-1 "/docker-entrypoint.…" proxy running 0.0.0.0:80->80/tcp ``` After the application starts, navigate to `http://localhost:80` in your web browser or run: + ``` $ curl localhost:80 @@ -82,11 +87,12 @@ $ curl localhost:80 \ \ __/ \____\_______/ - + Hello from Docker! ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/nginx-nodejs-redis/README.md b/nginx-nodejs-redis/README.md index 41a0d2a..29d5089 100644 --- a/nginx-nodejs-redis/README.md +++ b/nginx-nodejs-redis/README.md @@ -3,6 +3,7 @@ ## Node.js application with Nginx proxy and Redis database Project structure: + ``` . ├── README.md @@ -19,7 +20,9 @@ Project structure: ``` + [_compose.yaml_](compose.yaml) + ``` redis: image: 'redislabs/redismod' @@ -45,36 +48,34 @@ redis: - web1 - 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. - > ℹ️ **_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. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d [+] Running 24/24 ⠿ redis Pulled ... - ⠿ 565225d89260 Pull complete + ⠿ 565225d89260 Pull complete [+] Building 2.4s (22/25) => [nginx-nodejs-redis_nginx internal] load build definition from Dockerfile ... [+] Running 5/5 - ⠿ Network nginx-nodejs-redis_default Created - ⠿ Container nginx-nodejs-redis-web2-1 Started - ⠿ Container nginx-nodejs-redis-redis-1 Started - ⠿ Container nginx-nodejs-redis-web1-1 Started + ⠿ Network nginx-nodejs-redis_default Created + ⠿ Container nginx-nodejs-redis-web2-1 Started + ⠿ Container nginx-nodejs-redis-redis-1 Started + ⠿ Container nginx-nodejs-redis-web1-1 Started ⠿ Container nginx-nodejs-redis-nginx-1 Started ``` - ## Expected result Listing containers must show three containers running and the port mapping as below: - ``` docker-compose ps ``` @@ -93,16 +94,14 @@ web1: Total number of visits is: 1 curl localhost:80 web1: Total number of visits is: 2 ``` + ``` $ curl localhost:80 web2: Total number of visits is: 3 ``` - - ## Stop and remove the containers ``` -$ docker compose down +$ docker-compose down ``` - diff --git a/nginx-wsgi-flask/README.md b/nginx-wsgi-flask/README.md index 96dc33d..15d7cc7 100644 --- a/nginx-wsgi-flask/README.md +++ b/nginx-wsgi-flask/README.md @@ -40,7 +40,7 @@ Make sure port 80 on the host is not being used by another container, otherwise ## Deploy with docker compose ```bash -$ docker compose up -d +$ docker-compose up -d Creating network "nginx-wsgi-flask_default" with the default driver Building flask-app ... @@ -71,7 +71,7 @@ Hello World! Stop and remove the containers ```bash -$ docker compose down +$ docker-compose down Stopping nginx-wsgi-flask_nginx-proxy_1 ... done Stopping nginx-wsgi-flask_flask-app_1 ... done Removing nginx-wsgi-flask_nginx-proxy_1 ... done @@ -99,6 +99,6 @@ Flask is a web development framework written in Python. It is the "backend" whic A couple of sample endpoints are provided in this `docker-compose` example: -* `/` - Returns a "Hello World!" string. -* `/cache-me` - Returns a string which is cached by the NGINX reverse proxy. This demonstrates an intermediary cache implementation. -* `/info` - Returns informational headers about the request. Some are passed from NGINX for added client visibility. +- `/` - Returns a "Hello World!" string. +- `/cache-me` - Returns a string which is cached by the NGINX reverse proxy. This demonstrates an intermediary cache implementation. +- `/info` - Returns informational headers about the request. Some are passed from NGINX for added client visibility. diff --git a/official-documentation-samples/django/README.md b/official-documentation-samples/django/README.md index f7add9f..257caaa 100644 --- a/official-documentation-samples/django/README.md +++ b/official-documentation-samples/django/README.md @@ -10,14 +10,14 @@ and a `docker-compose.yml` file. (You can use either a `.yml` or `.yaml` extensi 1. Create an empty project directory. - You can name the directory something easy for you to remember. This directory is the context for your application image. The directory should only contain resources to build that image. + You can name the directory something easy for you to remember. This directory is the context for your application image. The directory should only contain resources to build that image. 2. Create a new file called `Dockerfile` in your project directory. - The Dockerfile defines an application's image content via one or more build - commands that configure that image. Once built, you can run the image in a - container. For more information on `Dockerfile`, see the [Docker user guide](https://docs.docker.com/get-started/) - and the [Dockerfile reference](https://docs.docker.com/engine/reference/builder/). + The Dockerfile defines an application's image content via one or more build + commands that configure that image. Once built, you can run the image in a + container. For more information on `Dockerfile`, see the [Docker user guide](https://docs.docker.com/get-started/) + and the [Dockerfile reference](https://docs.docker.com/engine/reference/builder/). 3. Add the following content to the `Dockerfile`. @@ -40,26 +40,26 @@ and a `docker-compose.yml` file. (You can use either a `.yml` or `.yaml` extensi 5. Create a `requirements.txt` in your project directory. - This file is used by the `RUN pip install -r requirements.txt` command in your `Dockerfile`. + This file is used by the `RUN pip install -r requirements.txt` command in your `Dockerfile`. 6. Add the required software in the file. - ```python - Django>=3.0,<4.0 - psycopg2>=2.8 - ``` + ```python + Django>=3.0,<4.0 + psycopg2>=2.8 + ``` 7. Save and close the `requirements.txt` file. 8. Create a file called `docker-compose.yml` in your project directory. - The `docker-compose.yml` file describes the services that make your app. In - this example those services are a web server and database. The compose file - also describes which Docker images these services use, how they link - together, any volumes they might need to be mounted inside the containers. - Finally, the `docker-compose.yml` file describes which ports these services - expose. See the [`docker-compose.yml` reference](https://docs.docker.com/compose/compose-file/) for more - information on how this file works. + The `docker-compose.yml` file describes the services that make your app. In + this example those services are a web server and database. The compose file + also describes which Docker images these services use, how they link + together, any volumes they might need to be mounted inside the containers. + Finally, the `docker-compose.yml` file describes which ports these services + expose. See the [`docker-compose.yml` reference](https://docs.docker.com/compose/compose-file/) for more + information on how this file works. 9. Add the following configuration to the file. @@ -79,7 +79,7 @@ and a `docker-compose.yml` file. (You can use either a `.yml` or `.yaml` extensi volumes: - .:/code ports: - - "8000:8000" + - '8000:8000' environment: - POSTGRES_NAME=postgres - POSTGRES_USER=postgres @@ -104,11 +104,11 @@ In this step, you create a Django starter project by building the image from the 1. Change to the root of your project directory. -2. Create the Django project by running the [docker compose run](https://docs.docker.com/engine/reference/commandline/compose_run/) +2. Create the Django project by running the [docker-compose run](https://docs.docker.com/engine/reference/commandline/compose_run/) command as follows. ```console - sudo docker compose run web django-admin startproject composeexample . + sudo docker-compose run web django-admin startproject composeexample . ``` This instructs Compose to run `django-admin startproject composeexample` @@ -121,7 +121,7 @@ In this step, you create a Django starter project by building the image from the instructs Django to create a set of files and directories representing a Django project. -3. After the `docker compose` command completes, list the contents of your project. +3. After the `docker-compose` command completes, list the contents of your project. ```console $ ls -l @@ -169,11 +169,11 @@ In this section, you set up the database connection for Django. ```python # settings.py - + import os - + [...] - + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', @@ -192,10 +192,10 @@ In this section, you set up the database connection for Django. 3. Save and close the file. -4. Run the [docker compose up](https://docs.docker.com/engine/reference/commandline/compose_up/) command from the top level directory for your project. +4. Run the [docker-compose up](https://docs.docker.com/engine/reference/commandline/compose_up/) command from the top level directory for your project. ```console - $ docker compose up + $ docker-compose up djangosample_db_1 is up-to-date Creating djangosample_web_1 ... @@ -233,8 +233,8 @@ In this section, you set up the database connection for Django. > ALLOWED_HOSTS = ['*'] > ``` > - > This value is **not** safe for production usage. Refer to the - > [Django documentation](https://docs.djangoproject.com/en/1.11/ref/settings/#allowed-hosts) for more information. + > This value is **not** safe for production usage. Refer to the + > [Django documentation](https://docs.djangoproject.com/en/1.11/ref/settings/#allowed-hosts) for more information. 5. List running containers. @@ -250,37 +250,37 @@ In this section, you set up the database connection for Django. 6. Shut down services and clean up by using either of these methods: - * Stop the application by typing `Ctrl-C` in the same shell in where you - started it: + - Stop the application by typing `Ctrl-C` in the same shell in where you + started it: - ```console - Gracefully stopping... (press Ctrl+C again to force) - Killing test_web_1 ... done - Killing test_db_1 ... done - ``` + ```console + Gracefully stopping... (press Ctrl+C again to force) + Killing test_web_1 ... done + Killing test_db_1 ... done + ``` - * Or, for a more elegant shutdown, switch to a different shell, and run - [docker compose down](https://docs.docker.com/engine/reference/commandline/compose_down/) from the top level of your - Django sample project directory. + - Or, for a more elegant shutdown, switch to a different shell, and run + [docker-compose down](https://docs.docker.com/engine/reference/commandline/compose_down/) from the top level of your + Django sample project directory. - ```console - $ docker compose down + ```console + $ docker-compose down - Stopping django_web_1 ... done - Stopping django_db_1 ... done - Removing django_web_1 ... done - Removing django_web_run_1 ... done - Removing django_db_1 ... done - Removing network django_default - ``` + Stopping django_web_1 ... done + Stopping django_db_1 ... done + Removing django_web_1 ... done + Removing django_web_run_1 ... done + Removing django_db_1 ... done + Removing network django_default + ``` - Once you've shut down the app, you can safely remove the Django project directory (for example, `rm -rf django`). +Once you've shut down the app, you can safely remove the Django project directory (for example, `rm -rf django`). ## More Compose documentation -* [Docker Compose overview](https://docs.docker.com/compose/) -* [Install Docker Compose](https://docs.docker.com/compose/install/) -* [Getting Started with Docker Compose](https://docs.docker.com/compose/gettingstarted/) -* [Docker Compose Command line reference](https://docs.docker.com/compose/reference/) -* [Compose file reference](https://docs.docker.com/compose/compose-file/) -* [Awesome Compose Django sample application](../../django/README.md) +- [Docker Compose overview](https://docs.docker.com/compose/) +- [Install Docker Compose](https://docs.docker.com/compose/install/) +- [Getting Started with Docker Compose](https://docs.docker.com/compose/gettingstarted/) +- [Docker Compose Command line reference](https://docs.docker.com/compose/reference/) +- [Compose file reference](https://docs.docker.com/compose/compose-file/) +- [Awesome Compose Django sample application](../../django/README.md) diff --git a/official-documentation-samples/rails/README.md b/official-documentation-samples/rails/README.md index 52e8dab..eed8ba3 100644 --- a/official-documentation-samples/rails/README.md +++ b/official-documentation-samples/rails/README.md @@ -7,7 +7,7 @@ a Rails/PostgreSQL app. Before starting, [install Compose](https://docs.docker.c Start by setting up the files needed to build the app. The app will run inside a Docker container containing its dependencies. Defining dependencies is done using -a file called `Dockerfile`. To begin with, the Dockerfile consists of: +a file called `Dockerfile`. To begin with, the Dockerfile consists of: ```dockerfile # syntax=docker/dockerfile:1 @@ -82,7 +82,7 @@ services: volumes: - .:/myapp ports: - - "3000:3000" + - '3000:3000' depends_on: - db ``` @@ -94,10 +94,10 @@ services: ### Build the project With those files in place, you can now generate the Rails skeleton app -using [docker compose run](https://docs.docker.com/engine/reference/commandline/compose_run/): +using [docker-compose run](https://docs.docker.com/engine/reference/commandline/compose_run/): ```console -$ docker compose run --no-deps web rails new . --force --database=postgresql +$ docker-compose run --no-deps web rails new . --force --database=postgresql ``` First, Compose builds the image for the `web` service using the `Dockerfile`. @@ -148,7 +148,7 @@ changes to the `Gemfile` or the Dockerfile, should be the only times you’ll ne to rebuild.) ```console -$ docker compose build +$ docker-compose build ``` ### Connect the database @@ -173,17 +173,16 @@ development: <<: *default database: myapp_development - test: <<: *default database: myapp_test ``` -You can now boot the app with [docker compose up](https://docs.docker.com/engine/reference/commandline/compose_up/). +You can now boot the app with [docker-compose up](https://docs.docker.com/engine/reference/commandline/compose_up/). If all is well, you should see some PostgreSQL output: ```console -$ docker compose up +$ docker-compose up rails_db_1 is up-to-date Creating rails_web_1 ... done @@ -200,7 +199,7 @@ db_1 | 2018-03-21 20:18:37.772 UTC [1] LOG: database system is ready to accep Finally, you need to create the database. In another terminal, run: ```console -$ docker compose run web rake db:create +$ docker-compose run web rake db:create Starting rails_db_1 ... done Created database 'myapp_development' Created database 'myapp_test' @@ -217,13 +216,13 @@ browser to see the Rails Welcome. ### Stop the application -To stop the application, run [docker compose down](https://docs.docker.com/engine/reference/commandline/compose_down/) in +To stop the application, run [docker-compose down](https://docs.docker.com/engine/reference/commandline/compose_down/) in your project directory. You can use the same terminal window in which you started the database, or another one where you have access to a command prompt. This is a clean way to stop the application. ```console -$ docker compose down +$ docker-compose down Stopping rails_web_1 ... done Stopping rails_db_1 ... done @@ -236,15 +235,15 @@ Removing network rails_default ### Restart the application -To restart the application run `docker compose up` in the project directory. +To restart the application run `docker-compose up` in the project directory. ### Rebuild the application If you make changes to the Gemfile or the Compose file to try out some different configurations, you need to rebuild. Some changes require only -`docker compose up --build`, but a full rebuild requires a re-run of -`docker compose run web bundle install` to sync changes in the `Gemfile.lock` to -the host, followed by `docker compose up --build`. +`docker-compose up --build`, but a full rebuild requires a re-run of +`docker-compose run web bundle install` to sync changes in the `Gemfile.lock` to +the host, followed by `docker-compose up --build`. Here is an example of the first case, where a full rebuild is not necessary. Suppose you simply want to change the exposed port on the local host from `3000` @@ -254,10 +253,10 @@ the changes: ```yaml ports: - - "3001:3000" + - '3001:3000' ``` -Now, rebuild and restart the app with `docker compose up --build`. +Now, rebuild and restart the app with `docker-compose up --build`. Inside the container, your app is running on the same port as before `3000`, but the Rails Welcome is now available on `http://localhost:3001` on your local @@ -265,8 +264,8 @@ host. ## More Compose documentation -* [Docker Compose overview](https://docs.docker.com/compose/) -* [Install Docker Compose](https://docs.docker.com/compose/install/) -* [Getting Started with Docker Compose](https://docs.docker.com/compose/gettingstarted/) -* [Docker Compose Command line reference](https://docs.docker.com/compose/reference/) -* [Compose file reference](https://docs.docker.com/compose/compose-file/) +- [Docker Compose overview](https://docs.docker.com/compose/) +- [Install Docker Compose](https://docs.docker.com/compose/install/) +- [Getting Started with Docker Compose](https://docs.docker.com/compose/gettingstarted/) +- [Docker Compose Command line reference](https://docs.docker.com/compose/reference/) +- [Compose file reference](https://docs.docker.com/compose/compose-file/) diff --git a/official-documentation-samples/wordpress/README.md b/official-documentation-samples/wordpress/README.md index 20623c9..5ae3a22 100644 --- a/official-documentation-samples/wordpress/README.md +++ b/official-documentation-samples/wordpress/README.md @@ -16,8 +16,8 @@ Compose to set up and run WordPress. Before starting, make sure you have This project directory contains a `docker-compose.yml` file which is complete in itself for a good starter wordpress project. - >**Tip**: You can use either a `.yml` or `.yaml` extension for - this file. They both work. + > **Tip**: You can use either a `.yml` or `.yaml` extension for + > this file. They both work. 2. Change into your project directory. @@ -67,24 +67,24 @@ Compose to set up and run WordPress. Before starting, make sure you have wp_data: ``` - > **Notes**: - > - * The docker volumes `db_data` and `wordpress_data` persists updates made by WordPress - to the database, as well as the installed themes and plugins. [Learn more about docker volumes](https://docs.docker.com/storage/volumes/) - > - * WordPress Multisite works only on ports `80` and `443`. - {: .note-vanilla} +> **Notes**: + +- The docker volumes `db_data` and `wordpress_data` persists updates made by WordPress + to the database, as well as the installed themes and plugins. [Learn more about docker volumes](https://docs.docker.com/storage/volumes/) + > +- WordPress Multisite works only on ports `80` and `443`. + {: .note-vanilla} ### Build the project -Now, run `docker compose up -d` from your project directory. +Now, run `docker-compose up -d` from your project directory. -This runs [`docker compose up`](https://docs.docker.com/engine/reference/commandline/compose_up/) in detached mode, pulls +This runs [`docker-compose up`](https://docs.docker.com/engine/reference/commandline/compose_up/) in detached mode, pulls the needed Docker images, and starts the wordpress and database containers, as shown in the example below. ```console -$ docker compose up -d +$ docker-compose up -d Creating network "my_wordpress_default" with the default driver Pulling db (mysql:5.7)... @@ -107,9 +107,9 @@ Creating my_wordpress_wordpress_1 ``` > **Note**: WordPress Multisite works only on ports `80` and/or `443`. -If you get an error message about binding `0.0.0.0` to port `80` or `443` -(depending on which one you specified), it is likely that the port you -configured for WordPress is already in use by another service. +> If you get an error message about binding `0.0.0.0` to port `80` or `443` +> (depending on which one you specified), it is likely that the port you +> configured for WordPress is already in use by another service. ### Bring up WordPress in a web browser @@ -118,8 +118,8 @@ and you can complete the "famous five-minute installation" as a WordPress administrator. > **Note**: The WordPress site is not immediately available on port `80` -because the containers are still being initialized and may take a couple of -minutes before the first load. +> because the containers are still being initialized and may take a couple of +> minutes before the first load. If you are using Docker Desktop for Mac or Docker Desktop for Windows, you can use `http://localhost` as the IP address, and open `http://localhost:80` in a web @@ -131,17 +131,17 @@ browser. ### Shutdown and cleanup -The command [`docker compose down`](https://docs.docker.com/engine/reference/commandline/compose_down/) removes the +The command [`docker-compose down`](https://docs.docker.com/engine/reference/commandline/compose_down/) removes the containers and default network, but preserves your WordPress database. -The command `docker compose down --volumes` removes the containers, default +The command `docker-compose down --volumes` removes the containers, default network, and the WordPress database. ## More Compose documentation -* [Docker Compose overview](https://docs.docker.com/compose/) -* [Install Docker Compose](https://docs.docker.com/compose/install/) -* [Getting Started with Docker Compose](https://docs.docker.com/compose/gettingstarted/) -* [Docker Compose Command line reference](https://docs.docker.com/compose/reference/) -* [Compose file reference](https://docs.docker.com/compose/compose-file/) -* [Awesome Compose WordPress sample](../../wordpress-mysql/README.md) +- [Docker Compose overview](https://docs.docker.com/compose/) +- [Install Docker Compose](https://docs.docker.com/compose/install/) +- [Getting Started with Docker Compose](https://docs.docker.com/compose/gettingstarted/) +- [Docker Compose Command line reference](https://docs.docker.com/compose/reference/) +- [Compose file reference](https://docs.docker.com/compose/compose-file/) +- [Awesome Compose WordPress sample](../../wordpress-mysql/README.md) diff --git a/pihole-cloudflared-DoH/README.md b/pihole-cloudflared-DoH/README.md index 02610d6..6240705 100644 --- a/pihole-cloudflared-DoH/README.md +++ b/pihole-cloudflared-DoH/README.md @@ -1,9 +1,10 @@ ## Pi-hole with cloudflared DoH (DNS-Over-HTTPS) + This example provides a base setup for using [Pi-hole](https://docs.pi-hole.net/) with the [cloudflared DoH](https://docs.pi-hole.net/guides/dns/cloudflared/) service. More details on how to customize the installation and the compose file can be found in [Docker Pi-hole documentation](https://github.com/pi-hole/docker-pi-hole). - Project structure: + ``` . ├── .env @@ -12,7 +13,8 @@ Project structure: ``` [_compose.yaml_](compose.yaml) -``` yaml + +```yaml services: pihole: image: pihole/pihole:latest @@ -34,7 +36,9 @@ services: ## Configuration ### .env + Before deploying this setup, you need to configure the following values in the [.env](.env) file. + - TZ ([time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)) - PIHOLE_PW (admin password) - PIHOLE_ROUTER_IP (only needed for activated conditional forwarding) @@ -43,29 +47,33 @@ Before deploying this setup, you need to configure the following values in the [ - PIHOLE_HOST_IPV6 (IPv6 address of your Pi-hole - can be empty if you only use IPv4) ### Conditional forwarding (optional, default: enabled) + If you would like to disable conditional forwarding, delete the environment variables starting with "CONDITIONAL_FORWARDING" ### 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: -``` yaml + +In the docker compose file, dns is added as a comment. To enable dns remove '#' in front of the following lines: + +```yaml 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 - - 1.1.1.1 # Backup server + - 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 ``` ## Deploy with docker compose + When deploying this setup, the admin web interface will be available on port 8080 (e.g. http://localhost:8080/admin). -``` shell -$ docker compose up -d +```shell +$ docker-compose up -d Starting cloudflared ... done Starting pihole ... done ``` - ## Expected result Check containers are running and the port mapping: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -75,34 +83,40 @@ dfd49ab7a372 visibilityspots/cloudflared "/bin/sh -c '/usr/lo…" Navigate to `http://localhost:8080` in your web browser to access the installed Pi-hole web interface. - Stop the containers with -``` shell -$ docker compose down + +```shell +$ docker-compose down # To delete all data run: -$ docker compose down -v +$ docker-compose down -v ``` ## Troubleshooting ### - Starting / Stopping pihole-FTL loop: - Sometimes, it can happen that there occurs a problem starting pihole-FTL. - I personally had this issue when adding this line to the shared volumes: - ``` - - "/pihole/pihole.log:/var/log/pihole.log" - ``` - To fix this issue, I found this [issue](https://github.com/pi-hole/docker-pi-hole/issues/645#issuecomment-670809672), - which suggested adding an empty file (`touch /pihole/pihole.log`) to prevent it from creating a directory. - The directory would not allow starting pihole-FTL and result in something like this: - ``` - # Starting pihole-FTL (no-daemon) as root - # Stopping pihole-FTL - ... - ``` - If you created an empty file, you may also check the ownership to prevent permission problems. - + +Sometimes, it can happen that there occurs a problem starting pihole-FTL. +I personally had this issue when adding this line to the shared volumes: + +``` +- "/pihole/pihole.log:/var/log/pihole.log" +``` + +To fix this issue, I found this [issue](https://github.com/pi-hole/docker-pi-hole/issues/645#issuecomment-670809672), +which suggested adding an empty file (`touch /pihole/pihole.log`) to prevent it from creating a directory. +The directory would not allow starting pihole-FTL and result in something like this: + +``` +# Starting pihole-FTL (no-daemon) as root +# Stopping pihole-FTL +... +``` + +If you created an empty file, you may also check the ownership to prevent permission problems. + ### - Installing on Ubuntu may conflict with `systemd-resolved` - see [Installing on Ubuntu](https://github.com/pi-hole/docker-pi-hole#installing-on-ubuntu-or-fedora) for help. ### - Environment variables are version-dependent - Environment variables like "CONDIIONAL_FORWARDING*" and "DNS1" are deprecated and replaced by e.g. "REV_SERVER*" and "PIHOLE_DNS" in version 5.8+. - Current information about environment variables can be found here: https://github.com/pi-hole/docker-pi-hole \ No newline at end of file + +Environment variables like "CONDIIONAL_FORWARDING*" and "DNS1" are deprecated and replaced by e.g. "REV_SERVER*" and "PIHOLE_DNS" in version 5.8+. +Current information about environment variables can be found here: https://github.com/pi-hole/docker-pi-hole diff --git a/plex/README.md b/plex/README.md index 9685267..951af73 100644 --- a/plex/README.md +++ b/plex/README.md @@ -1,10 +1,11 @@ ## Plex + This example provides a base setup for using [Plex](https://www.plex.tv/). More details on how to customize the installation and the compose file can be found in [linuxserver documentation](https://github.com/linuxserver/docker-plex). Alternatively, you can use different plex images (e.g. official plex image by [plexinc](https://github.com/plexinc/pms-docker)) - Project structure: + ``` . ├── .env @@ -13,7 +14,8 @@ Project structure: ``` [_compose.yaml_](compose.yaml) -``` yaml + +```yaml services: plex: image: linuxserver/plex:latest @@ -22,24 +24,28 @@ services: ## Configuration ### .env + Before deploying this setup, you need to configure the following values in the [.env](.env) file. + - PLEX_MEDIA_PATH ### Hardware Acceleration + Check out the description for Hardware Acceleration support in the [documentation](https://github.com/linuxserver/docker-plex). ## Deploy with docker compose + When deploying this setup, the web interface will be available on port 32400 (e.g. http://localhost:32400/web). -``` shell -$ docker compose up -d +```shell +$ docker-compose up -d Starting plex ... done ``` - ## Expected result Check containers are running: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -48,10 +54,10 @@ CONTAINER ID IMAGE COMMAND CREATE Navigate to `http://localhost:32400/web` in your web browser to access the plex web interface. - Stop the containers with -``` shell -$ docker compose down + +```shell +$ docker-compose down # To delete all data run: -$ docker compose down -v +$ docker-compose down -v ``` diff --git a/portainer/README.md b/portainer/README.md index f5c4344..a715a28 100644 --- a/portainer/README.md +++ b/portainer/README.md @@ -1,13 +1,17 @@ ## Portainer (CE) + This example provides a base setup for using [Portainer](https://www.portainer.io/). More details on how to customize the installation and the compose file can be found in [portainer documentation](https://documentation.portainer.io/). ### Demo + You can try out the public demo instance first: http://demo.portainer.io/ + - username: admin - password: tryportainer Project structure: + ``` . ├── compose.yaml @@ -15,24 +19,26 @@ Project structure: ``` [_compose.yaml_](compose.yaml) -``` yaml + +```yaml services: portainer: image: portainer/portainer-ce:alpine ``` ## Deploy with docker compose + When deploying this setup, the web interface will be available on port 9000 (e.g. http://localhost:9000). -``` shell -$ docker compose up -d +```shell +$ docker-compose up -d Starting portainer ... done ``` - ## Expected result Check containers are running: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -42,15 +48,16 @@ CONTAINER ID IMAGE COMMAND CREATED Navigate to `http://localhost:9000` in your web browser to access the portainer web interface and create an account. - Stop the containers with -``` shell -$ docker compose down + +```shell +$ docker-compose down # To delete all data run: -$ docker compose down -v +$ docker-compose down -v ``` ## Troubleshooting + - Select the correct image for your OS. You can take a look at the published tags at [DockerHub](https://hub.docker.com/r/portainer/portainer-ce/tags) - -> e.g. currently, the latest tag is for Windows (amd64) and alpine for Linux (amd64, arm/v7) \ No newline at end of file + +> e.g. currently, the latest tag is for Windows (amd64) and alpine for Linux (amd64, arm/v7) diff --git a/postgresql-pgadmin/README.md b/postgresql-pgadmin/README.md index 2b9a857..8585cf9 100644 --- a/postgresql-pgadmin/README.md +++ b/postgresql-pgadmin/README.md @@ -1,8 +1,10 @@ ## PostgreSQL and pgAdmin + This example provides a base setup for using [PostgreSQL](https://www.postgresql.org/) and [pgAdmin](https://www.pgadmin.org/). More details on how to customize the installation and the compose file can be found [here (PostgreSQL)](https://hub.docker.com/_/postgres) and [here (pgAdmin)](https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html). Project structure: + ``` . ├── .env @@ -11,7 +13,8 @@ Project structure: ``` [_compose.yaml_](compose.yaml) -``` yaml + +```yaml services: postgres: image: postgres:latest @@ -23,7 +26,9 @@ services: ## Configuration ### .env + Before deploying this setup, you need to configure the following values in the [.env](.env) file. + - POSTGRES_USER - POSTGRES_PW - POSTGRES_DB (can be default value) @@ -31,28 +36,33 @@ Before deploying this setup, you need to configure the following values in the [ - PGADMIN_PW ## Deploy with docker compose -When deploying this setup, the pgAdmin web interface will be available at port 5050 (e.g. http://localhost:5050). -``` shell -$ docker compose up +When deploying this setup, the pgAdmin web interface will be available at port 5050 (e.g. http://localhost:5050). + +```shell +$ docker-compose up Starting postgres ... done Starting pgadmin ... done ``` ## Add postgres database to pgAdmin -After logging in with your credentials of the .env file, you can add your database to pgAdmin. + +After logging in with your credentials of the .env file, you can add your database to pgAdmin. + 1. Right-click "Servers" in the top-left corner and select "Create" -> "Server..." 2. Name your connection 3. Change to the "Connection" tab and add the connection details: + - Hostname: "postgres" (this would normally be your IP address of the postgres database - however, docker can resolve this container ip by its name) - Port: "5432" - Maintenance Database: $POSTGRES_DB (see .env) - Username: $POSTGRES_USER (see .env) - Password: $POSTGRES_PW (see .env) - + ## Expected result Check containers are running: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -61,8 +71,9 @@ d3cde3b455ee dpage/pgadmin4:latest "/entrypoint.sh" 9 minute ``` Stop the containers with -``` shell -$ docker compose down + +```shell +$ docker-compose down # To delete all data run: -$ docker compose down -v +$ docker-compose down -v ``` diff --git a/prometheus-grafana/README.md b/prometheus-grafana/README.md index ae62ba9..51d6cf8 100644 --- a/prometheus-grafana/README.md +++ b/prometheus-grafana/README.md @@ -1,7 +1,9 @@ ## Compose sample + ### Prometheus & Grafana Project structure: + ``` . ├── compose.yaml @@ -13,6 +15,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: prometheus: @@ -26,6 +29,7 @@ services: ports: - 3000:3000 ``` + 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. Make sure the ports 9090 and 3000 on the host are not already in use. @@ -33,7 +37,7 @@ Make sure the ports 9090 and 3000 on the host are not already in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "prometheus-grafana_default" with the default driver Creating volume "prometheus-grafana_prom_data" with default driver ... @@ -46,6 +50,7 @@ Attaching to prometheus, grafana ## Expected result Listing containers must show two containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -60,6 +65,7 @@ Navigate to `http://localhost:3000` in your web browser and use the login creden Navigate to `http://localhost:9090` in your web browser to access directly the web interface of prometheus. 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 ``` diff --git a/react-express-mongodb/README.md b/react-express-mongodb/README.md index 69873cc..7f4f38e 100644 --- a/react-express-mongodb/README.md +++ b/react-express-mongodb/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### React application with a NodeJS backend and a MongoDB database Project structure: + ``` . ├── backend @@ -22,6 +23,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: frontend: @@ -48,6 +50,7 @@ services: restart: always ... ``` + 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. Make sure port 3000 on the host is not already being in use. @@ -55,7 +58,7 @@ Make sure port 3000 on the host is not already being in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "react-express-mongodb_default" with the default driver Building frontend Step 1/9 : FROM node:13.13.0-stretch-slim @@ -71,6 +74,7 @@ Creating app ... done ## Expected result Listing containers must show containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -84,8 +88,9 @@ After the application starts, navigate to `http://localhost:3000` in your web br ![page](./output.png) Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down Stopping server ... done Stopping frontend ... done Stopping mongo ... done @@ -96,46 +101,47 @@ Removing mongo ... done ##### Explanation of `docker-compose` -__Version__ +**Version** -The first line defines the version of a file. It sounds confusing :confused:. What is meant by version of file ?? +The first line defines the version of a file. It sounds confusing :confused:. What is meant by version of file ?? :pill: The Compose file is a YAML file defining services, networks, and volumes for a Docker application. So it is only a version of describing compose.yaml file. There are several versions of the Compose file format – 1, 2, 2.x, and 3.x. -__Services__ +**Services** -Our main goal to create a containers, it starts from here. As you can see there are three services(Docker images): -- First is __frontend__ -- Second is __server__ which is __backend - Express(NodeJS)__. I used a name server here, it's totally on you to name it __backend__. -- Third is __mongo__ which is db __MongoDB__. +Our main goal to create a containers, it starts from here. As you can see there are three services(Docker images): + +- First is **frontend** +- Second is **server** which is **backend - Express(NodeJS)**. I used a name server here, it's totally on you to name it **backend**. +- Third is **mongo** which is db **MongoDB**. ##### Service app (backend - NodeJS) We make image of app from our `Dockerfile`, explanation below. -__Explanation of service server__ +**Explanation of service server** -- Defining a **nodejs** service as __server__. -- We named our **node server** container service as **server**. Assigning a name to the containers makes it easier to read when there are lot of containers on a machine, it can also avoid randomly generated container names. (Although in this case, __container_name__ is also __server__, this is merely personal preference, the name of the service and container do not have to be the same.) +- Defining a **nodejs** service as **server**. +- We named our **node server** container service as **server**. Assigning a name to the containers makes it easier to read when there are lot of containers on a machine, it can also avoid randomly generated container names. (Although in this case, **container_name** is also **server**, this is merely personal preference, the name of the service and container do not have to be the same.) - Docker container starts automatically if its fails. -- Building the __server__ image using the Dockerfile from the current directory and passing an argument to the -backend(server) `DockerFile`. +- Building the **server** image using the Dockerfile from the current directory and passing an argument to the + backend(server) `DockerFile`. - Mapping the host port to the container port. ##### Service mongo -We add another service called **mongo** but this time instead of building it from `DockerFile` we write all the instruction here directly. We simply pull down the standard __mongo image__ from the [DockerHub](https://hub.docker.com/) registry as we have done it for Node image. +We add another service called **mongo** but this time instead of building it from `DockerFile` we write all the instruction here directly. We simply pull down the standard **mongo image** from the [DockerHub](https://hub.docker.com/) registry as we have done it for Node image. -__Explanation of service mongo__ +**Explanation of service mongo** -- Defining a **mongodb** service as __mongo__. +- Defining a **mongodb** service as **mongo**. - Pulling the mongo 4.2.0 image image again from [DockerHub](https://hub.docker.com/). -- Mount our current db directory to container. +- Mount our current db directory to container. - For persistent storage, we mount the host directory ( just like I did it in **Node** image inside `DockerFile` to reflect the changes) `/data` ( you need to create a directory in root of your project in order to save changes to locally as well) to the container directory `/data/db`, which was identified as a potential mount point in the `mongo Dockerfile` we saw earlier. - Mounting volumes gives us persistent storage so when starting a new container, Docker Compose will use the volume of any previous containers and copy it to the new container, ensuring that no data is lost. - Finally, we link/depends_on the app container to the mongo container so that the mongo service is reachable from the app service. - In last mapping the host port to the container port. -:key: `If you wish to check your DB changes on your local machine as well. You should have installed MongoDB locally, otherwise you can't access your mongodb service of container from host machine.` +:key: `If you wish to check your DB changes on your local machine as well. You should have installed MongoDB locally, otherwise you can't access your mongodb service of container from host machine.` -:white_check_mark: You should check your __mongo__ version is same as used in image. You can see the version of __mongo__ image in `docker-compose `file, I used __image: mongo:4.2.0__. If your mongo db version on your machine is not same then furst you have to updated your local __mongo__ version in order to works correctly. +:white_check_mark: You should check your **mongo** version is same as used in image. You can see the version of **mongo** image in `docker-compose `file, I used **image: mongo:4.2.0**. If your mongo db version on your machine is not same then furst you have to updated your local **mongo** version in order to works correctly. diff --git a/react-express-mysql/README.md b/react-express-mysql/README.md index 46c4e4c..ec20090 100644 --- a/react-express-mysql/README.md +++ b/react-express-mysql/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### React application with a NodeJS backend and a MySQL database Project structure: + ``` . ├── backend @@ -24,6 +25,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: backend: @@ -45,19 +47,20 @@ services: - 3000:3000 ... ``` + 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. Make sure port 3000 on the host is not already being in use. > ℹ️ **_INFO_** > For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL. -> 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` ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "react-express-mysql_default" with the default driver Building backend Step 1/16 : FROM node:10 @@ -73,6 +76,7 @@ Creating react-express-mysql_frontend_1 ... done ## Expected result Listing containers must show containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -85,16 +89,17 @@ After the application starts, navigate to `http://localhost:3000` in your web br ![page](./output.png) - The backend service container has the port 80 mapped to 80 on the host. + ``` $ curl localhost:80 {"message":"Hello from MySQL 8.0.19"} ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down Stopping react-express-mysql_frontend_1 ... done Stopping react-express-mysql_backend_1 ... done Stopping react-express-mysql_db_1 ... done diff --git a/react-java-mysql/README.md b/react-java-mysql/README.md index 94972d6..17668db 100644 --- a/react-java-mysql/README.md +++ b/react-java-mysql/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### React application with a Spring backend and a MySQL database Project structure: + ``` . ├── backend @@ -24,6 +25,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: backend: @@ -41,6 +43,7 @@ services: - 3000:3000 ... ``` + 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. Make sure port 3000 on the host is not already being in use. @@ -53,7 +56,7 @@ Make sure port 3000 on the host is not already being in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "react-java-mysql-default" with the default driver Building backend Step 1/17 : FROM maven:3.6.3-jdk-11 AS builder @@ -68,6 +71,7 @@ Creating react-java-mysql-backend-1 ... done ## Expected result Listing containers must show three containers running and the port mapping as below: + ``` $ docker ps ONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -80,8 +84,9 @@ After the application starts, navigate to `http://localhost:3000` in your web br ![page](./output.jpg) Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down Stopping react-java-mysql-backend-1 ... done Stopping react-java-mysql-frontend-1 ... done Stopping react-java-mysql-db-1 ... done diff --git a/react-nginx/README.md b/react-nginx/README.md index 7b7044a..202a2ca 100755 --- a/react-nginx/README.md +++ b/react-nginx/README.md @@ -41,12 +41,12 @@ services: ``` 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 ``` -$ docker compose up -d +$ docker-compose up -d Building frontend Sending build context to Docker daemon 1.49MB @@ -87,7 +87,7 @@ After the application start, navigate to http://localhost in your browser: Stop and remove the containers ``` -$ docker compose down +$ docker-compose down Stopping frontend ... done Removing frontend ... done Removing network react-nginx_default diff --git a/react-rust-postgres/readme.md b/react-rust-postgres/readme.md index 298de80..123f03d 100644 --- a/react-rust-postgres/readme.md +++ b/react-rust-postgres/readme.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### React application with a Rust backend and a Postgresql database Project structure: + ``` . ├── backend @@ -22,6 +23,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: backend: @@ -36,6 +38,7 @@ services: - 3000:3000 ... ``` + 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. Make sure port 3000 on the host is not already being in use. @@ -43,7 +46,7 @@ Make sure port 3000 on the host is not already being in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "react-rust-postgres_default" with the default driver Building backend ... @@ -57,6 +60,7 @@ Creating react-rust-postgres_backend_1 ... done ## Expected result Listing containers must show three containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -70,8 +74,9 @@ After the application starts, navigate to `http://localhost:3000` in your web br ![page](./capture.png) Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down Stopping react-rust-postgres_backend_1 ... done Stopping react-rust-postgres_frontend_1 ... done Stopping react-rust-postgres_db_1 ... done diff --git a/sparkjava-mysql/README.md b/sparkjava-mysql/README.md index 893ea3e..86ccac7 100644 --- a/sparkjava-mysql/README.md +++ b/sparkjava-mysql/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Java Spark application with MySQL database Project structure: + ``` . ├── backend @@ -22,6 +23,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: backend: @@ -35,19 +37,20 @@ services: #image: mysql:8.0.27 ... ``` + 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. Make sure port 8080 on the host is not already being in use. > ℹ️ **_INFO_** > For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL. -> 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` ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "sparkjava-mysql_default" with the default driver Building backend ... @@ -60,6 +63,7 @@ Creating sparkjava-mysql_backend_1 ... done ## Expected result Listing containers must show two containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -68,14 +72,16 @@ ee1e4f05d9f6 sparkjava-mysql_backend "/bin/sh -c 'java -j…" 44 seco ``` After the application starts, run: + ``` $ curl localhost:8080 ["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"] ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down Stopping sparkjava-mysql_backend_1 ... done Stopping sparkjava-mysql_db_1 ... done Removing sparkjava-mysql_backend_1 ... done diff --git a/sparkjava/README.md b/sparkjava/README.md index 83d9223..e5626b8 100644 --- a/sparkjava/README.md +++ b/sparkjava/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Spark Java Project structure: + ``` . ├── compose.yaml @@ -19,6 +20,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: sparkjava: @@ -26,6 +28,7 @@ services: ports: - 8080:8080 ``` + 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. Make sure port 8080 on the host is not already being in use. @@ -33,7 +36,7 @@ Make sure port 8080 on the host is not already being in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "sparkjava_default" with the default driver Building sparkjava Step 1/11 : FROM maven:3.6.3-jdk-11 AS build @@ -47,6 +50,7 @@ Creating sparkjava_sparkjava_1 ... done ## Expected result Listing containers must show one container running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -54,14 +58,16 @@ CONTAINER ID IMAGE COMMAND CREATED ``` After the application starts, navigate to `http://localhost:8080` in your web browser or run: + ``` $ curl localhost:8080 Hello from Docker! ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down Stopping sparkjava_sparkjava_1 ... done Removing sparkjava_sparkjava_1 ... done Removing network sparkjava_default diff --git a/spring-postgres/README.md b/spring-postgres/README.md index ca4e9cb..d65a9b8 100644 --- a/spring-postgres/README.md +++ b/spring-postgres/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### Java application with Spring framework and a Postgres database Project structure: + ``` . ├── backend @@ -22,6 +23,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: backend: @@ -32,6 +34,7 @@ services: image: postgres ... ``` + 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. Make sure port 8080 on the host is not already being in use. @@ -39,7 +42,7 @@ Make sure port 8080 on the host is not already being in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "spring-postgres_default" with the default driver Building backend Step 1/11 : FROM maven:3.5-jdk-9 AS build @@ -54,6 +57,7 @@ Creating spring-postgres_db_1 ... done ## Expected result Listing containers must show two containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -62,6 +66,7 @@ CONTAINER ID IMAGE COMMAND CREATED ``` After the application starts, navigate to `http://localhost:8080` in your web browse or run: + ``` $ curl localhost:8080 @@ -76,8 +81,9 @@ $ curl localhost:8080 ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down Stopping spring-postgres_db_1 ... done Stopping spring-postgres_backend_1 ... done Removing spring-postgres_db_1 ... done diff --git a/traefik-golang/README.md b/traefik-golang/README.md index 7a86e75..0137908 100644 --- a/traefik-golang/README.md +++ b/traefik-golang/README.md @@ -9,6 +9,7 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi ### TRAEFIK proxy with GO backend Project structure: + ``` . ├── backend @@ -19,6 +20,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: frontend: @@ -40,6 +42,7 @@ services: - "traefik.http.services.go.loadbalancer.server.port=80" ``` + 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. Make sure port 80 on the host is not already being in use. @@ -47,7 +50,7 @@ Make sure port 80 on the host is not already being in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "traefik-golang_default" with the default driver Building backend Step 1/7 : FROM golang:1.13 AS build @@ -71,6 +74,7 @@ Creating traefik-golang_frontend_1 ... done ## Expected result Listing containers must show two containers running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -79,6 +83,7 @@ e0a0f3191042 traefik:2.6 "/entrypoint.sh --pr…" 42 seconds ag ``` After the application starts, navigate to `http://localhost:80` in your web browser or run: + ``` $ curl localhost:80 @@ -96,6 +101,7 @@ Hello from Docker! ``` Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down ``` diff --git a/vuejs/README.md b/vuejs/README.md index 1fd4d1d..e2dceb5 100644 --- a/vuejs/README.md +++ b/vuejs/README.md @@ -6,9 +6,10 @@ You can open this sample in the Dev Environments feature of Docker Desktop versi [Open in Docker Dev Environments Open in Docker Dev Environments](https://open.docker.com/dashboard/dev-envs?url=https://github.com/docker/awesome-compose/tree/master/vuejs) -### VueJS +### VueJS Project structure: + ``` . ├── compose.yaml @@ -19,6 +20,7 @@ Project structure: ``` [_compose.yaml_](compose.yaml) + ``` services: web: @@ -29,6 +31,7 @@ services: - ./vuejs:/project - /project/node_modules ``` + 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. Make sure port 8080 on the host is not already being in use. @@ -36,7 +39,7 @@ Make sure port 8080 on the host is not already being in use. ## Deploy with docker compose ``` -$ docker compose up -d +$ docker-compose up -d Creating network "vuejs_default" with the default driver Building web Step 1/8 : FROM node:13.10.1-alpine @@ -49,6 +52,7 @@ Creating vuejs_web_1 ... done ## Expected result Listing containers must show one container running and the port mapping as below: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -60,8 +64,9 @@ After the application starts, navigate to `http://localhost:80` in your web brow ![page](output.jpg) Stop and remove the containers + ``` -$ docker compose down +$ docker-compose down Stopping vuejs_web_1 ... done Removing vuejs_web_1 ... done Removing network vuejs_default diff --git a/wireguard/README.md b/wireguard/README.md index e98a527..6233c1f 100644 --- a/wireguard/README.md +++ b/wireguard/README.md @@ -1,8 +1,10 @@ ## Wireguard + This example provides a base setup for using [Wireguard](https://www.wireguard.com/). More details on how to customize the installation and the compose file can be found in [linuxserver documentation](https://hub.docker.com/r/linuxserver/wireguard). Project structure: + ``` . ├── .env @@ -11,7 +13,8 @@ Project structure: ``` [_compose.yaml_](compose.yaml) -``` yaml + +```yaml services: wireguard: image: linuxserver/wireguard @@ -20,15 +23,18 @@ services: ## Configuration ### .env + Before deploying this setup, you need to configure the following values in the [.env](.env) file. + - TIMEZONE - 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 -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 -$ docker compose up +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 +$ docker-compose up Starting wireguard ... wireguard | **** It seems the wireguard module is already active. Skipping kernel header install and module compilation. **** wireguard | **** Server mode is selected **** @@ -43,6 +49,7 @@ wireguard | [GENERATED QR CODE TO SCAN FOR YOUR CONNECTION DETAILS] ## Expected result Check containers are running: + ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -52,27 +59,32 @@ CONTAINER ID IMAGE COMMAND CREATED ## Mobile Wireguard App ### Android + Install your Wireguard client on an Apple device by downloading the wireguard app and scanning the QR Code. ### iOS + Install your Wireguard client on an Apple device by downloading the wireguard app and scanning the QR Code. Stop the containers with -``` shell -$ docker compose down + +```shell +$ docker-compose down # To delete all data run: -$ docker compose down -v +$ docker-compose down -v ``` ## Troubleshooting ### - (Raspberry Pi) Kernel Headers - On Raspberry Pi run `sudo apt update && sudo apt upgrade && sudo apt install raspberrypi-kernel-headers` and reboot before starting Wireguard. - Other Ubuntu / Debian based systems may need to install the kernel-headers too. Run `sudo apt update && sudo apt upgrade && sudo apt install linux-headers-$(uname -r)` - + +On Raspberry Pi run `sudo apt update && sudo apt upgrade && sudo apt install raspberrypi-kernel-headers` and reboot before starting Wireguard. +Other Ubuntu / Debian based systems may need to install the kernel-headers too. Run `sudo apt update && sudo apt upgrade && sudo apt install linux-headers-$(uname -r)` + ### - Server Mode Options - To create new clients or display existing ones, take a look at the "[Server Mode](https://hub.docker.com/r/linuxserver/wireguard)" section \ No newline at end of file + +To create new clients or display existing ones, take a look at the "[Server Mode](https://hub.docker.com/r/linuxserver/wireguard)" section