### Start Application with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/rails/README.md Starts all services defined in the docker-compose.yml file. This command will show PostgreSQL initialization logs and indicate when the 'web' service is ready. ```console $ docker compose up rails_db_1 is up-to-date Creating rails_web_1 ... done Attaching to rails_db_1, rails_web_1 db_1 | PostgreSQL init process complete; ready for start up. db_1 | db_1 | 2018-03-21 20:18:37.437 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 db_1 | 2018-03-21 20:18:37.437 UTC [1] LOG: listening on IPv6 address "::", port 5432 db_1 | 2018-03-21 20:18:37.443 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" db_1 | 2018-03-21 20:18:37.726 UTC [55] LOG: database system was shut down at 2018-03-21 20:18:37 UTC db_1 | 2018-03-21 20:18:37.772 UTC [1] LOG: database system is ready to accept connections ``` -------------------------------- ### Start WordPress and Database Containers Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/wordpress/README.md Command to build and start the Docker containers defined in the `docker-compose.yml` file in detached mode. ```console $ docker compose up -d Creating network "my_wordpress_default" with the default driver Pulling db (mysql:5.7)... 5.7: Pulling from library/mysql efd26ecc9548: Pull complete a3ed95caeb02: Pull complete <...> Digest: sha256:34a0aca88e85f2efa5edff1cea77cf5d3147ad93545dbec99cfe705b03c520de Status: Downloaded newer image for mysql:5.7 Pulling wordpress (wordpress:latest)... latest: Pulling from library/wordpress efd26ecc9548: Already exists a3ed95caeb02: Pull complete 589a9d9a7c64: Pull complete <...> Digest: sha256:ed28506ae44d5def89075fd5c01456610cd6c64006addfe5210b8c675881aff6 Status: Downloaded newer image for wordpress:latest Creating my_wordpress_db_1 Creating my_wordpress_wordpress_1 ``` -------------------------------- ### Vue.js Project Setup Source: https://github.com/docker/awesome-compose/blob/master/vuejs/vuejs/README.md Installs project dependencies using yarn. ```bash yarn install ``` -------------------------------- ### Deploying the Application Source: https://github.com/docker/awesome-compose/blob/master/nginx-nodejs-redis/README.md Command to start all defined services in the background using Docker Compose. ```bash $ docker compose up -d ``` -------------------------------- ### Starting Django Application with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/django/README.md This console command initiates the Docker containers defined in a docker-compose.yml file. It builds and starts the services, in this case, a Django web application and a PostgreSQL database, displaying the logs from the running containers. ```console $ docker compose up djangosample_db_1 is up-to-date Creating djangosample_web_1 ... Creating djangosample_web_1 ... done Attaching to djangosample_db_1, djangosample_web_1 db_1 | The files belonging to this database system will be owned by user "postgres". db_1 | This user must also own the server process. db_1 | db_1 | The database cluster will be initialized with locale "en_US.utf8". db_1 | The default database encoding has accordingly been set to "UTF8". db_1 | The default text search configuration will be set to "english". <...> web_1 | July 30, 2020 - 18:35:38 web_1 | Django version 3.0.8, using settings 'composeexample.settings' web_1 | Starting development server at http://0.0.0.0:8000/ web_1 | Quit the server with CONTROL-C. ``` -------------------------------- ### Deploy Application with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-postgres/README.md Command to build and start the application services defined in the docker-compose.yaml file in detached mode. ```shell $ docker compose up -d Creating network "nginx-golang-postgres_default" with the default driver Pulling db (postgres:)... latest: Pulling from library/postgres ... Successfully built 5f7c899f9b49 Successfully tagged nginx-golang-postgres_proxy:latest WARNING: Image for service proxy was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating nginx-golang-postgres_db_1 ... done Creating nginx-golang-postgres_backend_1 ... done Creating nginx-golang-postgres_proxy_1 ... done ``` -------------------------------- ### Deploying the Application Source: https://github.com/docker/awesome-compose/blob/master/nginx-aspnet-mysql/README.md Command to start the application services defined in the Docker Compose file in detached mode. ```bash $ docker compose up -d ``` -------------------------------- ### Deploy Spark Java Application Source: https://github.com/docker/awesome-compose/blob/master/sparkjava/README.md Command to build and start the Docker Compose application in detached mode. It shows the output of creating the network, building the image, and starting the container. ```bash $ 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 3.6.3-jdk-11: Pulling from library/maven ... Successfully tagged sparkjava_sparkjava:latest WARNING: Image for service sparkjava was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating sparkjava_sparkjava_1 ... done ``` -------------------------------- ### Dockerfile for Rails App Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/rails/README.md Defines the Docker image for a Ruby on Rails application. It installs dependencies like Node.js and PostgreSQL client, sets up the working directory, copies application files, installs gems, and configures the entrypoint and command to run the Rails server. ```dockerfile # syntax=docker/dockerfile:1 FROM ruby:2.5 RUN apt-get update -qq && apt-get install -y nodejs postgresql-client WORKDIR /myapp COPY Gemfile /myapp/Gemfile COPY Gemfile.lock /myapp/Gemfile.lock RUN bundle install # Add a script to be executed every time the container starts. COPY entrypoint.sh /usr/bin/ RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT ["entrypoint.sh"] EXPOSE 3000 # Configure the main process to run when running the image CMD ["rails", "server", "-b", "0.0.0.0"] ``` -------------------------------- ### Deploy Gitea with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/gitea-postgres/README.md Command to deploy the Gitea and PostgreSQL services defined in the docker-compose.yaml file. It creates and starts the necessary containers and networks. ```bash $ 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 Attaching to gitea-postgres_db_1, gitea-postgres_gitea_1 .... Starting gitea-postgres_db_1 ... done Starting gitea-postgres_gitea_1 ... done ``` -------------------------------- ### Dockerfile for Django App Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/django/README.md Defines the Docker image for a Django application. It starts from a Python 3 base image, sets environment variables, copies requirements, installs dependencies, and copies the application code. ```dockerfile # syntax=docker/dockerfile:1 FROM python:3 ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 WORKDIR /code COPY requirements.txt /code/ RUN pip install -r requirements.txt COPY . /code/ ``` -------------------------------- ### Deploy Application with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/react-rust-postgres/readme.md Command to build images (if necessary) and start the application services in detached mode. ```bash $ docker compose up -d Creating network "react-rust-postgres_default" with the default driver Building backend ... Successfully tagged react-rust-postgres_frontend:latest WARNING: Image for service frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating react-rust-postgres_react-rust-postgres_frontend_1 ... done Creating react-rust-postgres_react-rust-postgres_db_1 ... done Creating react-rust-postgres_react-rust-postgres_backend_1 ... done ``` -------------------------------- ### Deploy Minecraft Server with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/minecraft/README.md Commands to deploy a Minecraft server using Docker Compose. This includes creating a data directory, starting the server in detached mode, and managing the server lifecycle. ```bash mkdir -p ~/minecraft_data docker compose up -d ``` ```bash docker compose down ``` ```bash docker compose down -v ``` -------------------------------- ### Deploying the Application Source: https://github.com/docker/awesome-compose/blob/master/react-java-mysql/README.md Command to build and start the application services in detached mode using Docker Compose. ```bash $ 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 ... Successfully tagged react-java-mysql_frontend:latest WARNING: Image for service frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating react-java-mysql-frontend-1 ... done Creating react-java-mysql-db-1 ... done Creating react-java-mysql-backend-1 ... done ``` -------------------------------- ### Deploying Wireguard with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/wireguard/README.md Commands to start and stop the Wireguard service using Docker Compose. Includes instructions for bringing the service up and down, with an option to remove volumes. ```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 **** wireguard | **** External server address is set to your-domain.dyndns.com # free examples http://www.duckdns.org/ and https://www.noip.com/ **** wireguard | **** External server port is set to 51820. Make sure that port is properly forwarded to port 51820 inside this container **** [...] wireguard | PEER 1 QR code: wireguard | [GENERATED QR CODE TO SCAN FOR YOUR CONNECTION DETAILS] ``` ```shell $ docker compose down # To delete all data run: $ docker compose down -v ``` -------------------------------- ### Deploying with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/react-express-mongodb/README.md Command to build and start the application services defined in the `compose.yaml` file in detached mode. ```bash $ docker compose up -d ``` -------------------------------- ### Docker Compose Deployment and Management Source: https://github.com/docker/awesome-compose/blob/master/apache-php/README.md Provides essential Docker Compose commands for managing the application. This includes starting the services in detached mode (`up -d`), viewing running containers (`ps`), and stopping and removing the services (`down`). ```bash $ docker compose up -d Creating network "php-docker_web" with the default driver Building web Step 1/6 : FROM php:7.2-apache ... ... Creating php-docker_web_1 ... done ``` ```bash $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2bc8271fee81 php-docker_web "docker-php-entrypoi…" About a minute ago Up About a minute 0.0.0.0:80->80/tc php-docker_web_1 ``` ```bash $ curl localhost:80 Hello World! ``` ```bash $ docker compose down ``` -------------------------------- ### Deploy VueJS Application with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/vuejs/README.md Commands to build, deploy, and manage the VueJS application using Docker Compose. Includes starting the application in detached mode, viewing running containers, and stopping/removing the application. ```bash $ docker compose up -d Creating network "vuejs_default" with the default driver Building web Step 1/8 : FROM node:13.10.1-alpine ... Successfully tagged vuejs_web:latest WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating vuejs_web_1 ... done ``` ```bash $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 701c02bb97b1 vuejs_web "docker-entrypoint.s…" 49 seconds ago Up 46 seconds 0.0.0.0:80->8080/tcp vuejs_web_1 ``` ```bash $ docker compose down Stopping vuejs_web_1 ... done Removing vuejs_web_1 ... done Removing network vuejs_default ``` -------------------------------- ### Deploy WordPress with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/wordpress-mysql/README.md Command to deploy the services defined in the Docker Compose file. This command creates the necessary network and volumes, then starts the WordPress and database containers in detached mode. ```bash $ docker compose up -d Creating network "wordpress-mysql_default" with the default driver Creating volume "wordpress-mysql_db_data" with default driver ... Creating wordpress-mysql_db_1 ... done Creating wordpress-mysql_wordpress_1 ... done ``` -------------------------------- ### List Project Files Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/rails/README.md Lists the files and directories generated after creating the Rails project, showing ownership, size, and modification dates. ```console $ ls -l total 64 -rw-r--r-- 1 vmb staff 222 Jun 7 12:05 Dockerfile -rw-r--r-- 1 vmb staff 1738 Jun 7 12:09 Gemfile -rw-r--r-- 1 vmb staff 4297 Jun 7 12:09 Gemfile.lock -rw-r--r-- 1 vmb staff 374 Jun 7 12:09 README.md -rw-r--r-- 1 vmb staff 227 Jun 7 12:09 Rakefile drwxr-xr-x 10 vmb staff 340 Jun 7 12:09 app drwxr-xr-x 8 vmb staff 272 Jun 7 12:09 bin drwxr-xr-x 14 vmb staff 476 Jun 7 12:09 config -rw-r--r-- 1 vmb staff 130 Jun 7 12:09 config.ru drwxr-xr-x 3 vmb staff 102 Jun 7 12:09 db -rw-r--r-- 1 vmb staff 211 Jun 7 12:06 docker-compose.yml -rw-r--r-- 1 vmb staff 184 Jun 7 12:08 entrypoint.sh drwxr-xr-x 4 vmb staff 136 Jun 7 12:09 lib drwxr-xr-x 3 vmb staff 102 Jun 7 12:09 log -rw-r--r-- 1 vmb staff 63 Jun 7 12:09 package.json drwxr-xr-x 9 vmb staff 306 Jun 7 12:09 public drwxr-xr-x 9 vmb staff 306 Jun 7 12:09 test drwxr-xr-x 4 vmb staff 136 Jun 7 12:09 tmp drwxr-xr-x 3 vmb staff 102 Jun 7 12:09 vendor ``` -------------------------------- ### Deploy Nextcloud with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/nextcloud-postgres/README.md This command initiates the deployment of the Nextcloud and Postgres services defined in the docker-compose.yaml file. It pulls necessary images, creates networks and volumes, and starts the containers in detached mode. ```bash $ 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)... .... .... Status: Downloaded newer image for postgres:alpine Creating nextcloud-postgres_nc_1 ... done Creating nextcloud-postgres_db_1 ... done ``` -------------------------------- ### Deploying with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/spring-postgres/README.md Commands to build the backend image and start the application services in detached mode. ```bash $ 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 3.5-jdk-9: Pulling from library/maven ... Successfully tagged spring-postgres_backend:latest WARNING: Image for service backend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating spring-postgres_backend_1 ... done Creating spring-postgres_db_1 ... done ``` -------------------------------- ### Vue.js Production Build Source: https://github.com/docker/awesome-compose/blob/master/vuejs/vuejs/README.md Compiles and minifies the Vue.js application for production deployment. ```bash yarn build ``` -------------------------------- ### Deploy and Manage Plex with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/plex/README.md Provides commands to deploy Plex using Docker Compose, check container status, and stop/remove the containers. It includes starting the service, viewing running containers, and shutting down the stack. ```shell $ docker compose up -d Starting plex ... done ``` ```shell $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 62fc3ff1f1a0 linuxserver/plex:latest "/init" 38 seconds ago Up 3 seconds plex ``` ```shell $ docker compose down # To delete all data run: $ docker compose down -v ``` -------------------------------- ### Entrypoint Script for Rails Container Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/rails/README.md A bash script executed when the container starts. It removes a pre-existing server.pid file to prevent issues with Rails server restarts and then executes the main container command. ```bash #!/bin/bash set -e # Remove a potentially pre-existing server.pid for Rails. rm -f /myapp/tmp/pids/server.pid # Then exec the container's main process (what's set as CMD in the Dockerfile). exec "$@" ``` -------------------------------- ### Starting Node.js App with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/react-express-mysql/backend/README.md This snippet shows the basic command to start a Node.js application using Docker Compose. It builds a custom development image with nodemon, exposes necessary ports, and mounts the current directory into the container. ```bash docker-compose up ``` -------------------------------- ### Build Rails Project with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/rails/README.md This command builds the Docker image for the 'web' service and runs the Rails new command to generate a new Rails application within a container. The `--no-deps` flag prevents linked services from starting. ```console $ docker compose run --no-deps web rails new . --force --database=postgresql ``` -------------------------------- ### Docker Compose Configuration for WordPress and MariaDB Source: https://github.com/docker/awesome-compose/blob/master/wordpress-mysql/README.md Defines the services for a WordPress application and its MariaDB database. It specifies the images to use, port mappings, and restart policies. The example prioritizes MariaDB for compatibility but shows how to switch to MySQL. ```yaml services: db: # We use a mariadb image which supports both amd64 & arm64 architecture image: mariadb:10.6.4-focal # If you really want to use MySQL, uncomment the following line #image: mysql:8.0.27 ... wordpress: image: wordpress:latest ports: - 80:80 restart: always ... ``` -------------------------------- ### Vue.js Linting Source: https://github.com/docker/awesome-compose/blob/master/vuejs/vuejs/README.md Lints and fixes project files using the configured linter. ```bash yarn lint ``` -------------------------------- ### Deploy Docker Compose Application Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang/README.md Command to build and start the services defined in the `docker-compose.yaml` file in detached mode. ```bash $ docker compose up -d ``` -------------------------------- ### Create Django Project with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/django/README.md This command initiates the creation of a new Django project named 'composeexample' within a Docker container. It leverages the 'web' service's image and build context defined in `docker-compose.yml`. The command builds the image if it doesn't exist and then executes `django-admin startproject`. ```console sudo docker compose run web django-admin startproject composeexample . ``` -------------------------------- ### Installing Wireguard Kernel Headers on Raspberry Pi/Debian Source: https://github.com/docker/awesome-compose/blob/master/wireguard/README.md Instructions for installing necessary kernel headers on Debian-based systems, specifically Raspberry Pi, to ensure Wireguard functionality. This is a prerequisite for running Wireguard. ```shell sudo apt update && sudo apt upgrade && sudo apt install raspberrypi-kernel-headers 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)` ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-postgres/README.md Defines the services for the application: a Go backend, a Postgres database, and an Nginx proxy. It specifies build contexts, images, volumes, and port mappings. ```yaml services: backend: build: context: backend target: builder ... db: image: postgres ... proxy: image: nginx volumes: - type: bind source: ./proxy/nginx.conf target: /etc/nginx/conf.d/default.conf read_only: true ports: - 80:80 ... ``` -------------------------------- ### Accessing the Application Source: https://github.com/docker/awesome-compose/blob/master/nginx-aspnet-mysql/README.md Demonstrates how to access the deployed application via a web browser or using curl, showing the expected JSON response from the backend service. ```bash $ curl localhost:80 ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-mysql/README.md Defines the services for the application: a Go backend, a MariaDB database, and an Nginx proxy. It specifies build contexts, Docker images, volume mounts, and port mappings. ```yaml services: backend: build: context: backend target: builder ... db: # We use a mariadb image which supports both amd64 & arm64 architecture image: mariadb:10-focal # If you really want to use MySQL, uncomment the following line #image: mysql:8 ... proxy: image: nginx volumes: - type: bind source: ./proxy/nginx.conf target: /etc/nginx/conf.d/default.conf read_only: true ports: - 80:80 ... ``` -------------------------------- ### Run Docker Compose Application Source: https://github.com/docker/awesome-compose/blob/master/README.md Starts all services defined in the compose.yaml file in detached mode. Requires Docker and Docker Compose to be installed. ```console docker compose up -d ``` -------------------------------- ### Deploy PostgreSQL and pgAdmin with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/postgresql-pgadmin/README.md Commands to start and stop the PostgreSQL and pgAdmin services using Docker Compose. 'docker compose up' starts the services, and 'docker compose down' stops them. The '-v' flag with 'down' is used to remove volumes and associated data. ```shell $ docker compose up Starting postgres ... done Starting pgadmin ... done ``` ```shell $ docker compose down # To delete all data run: $ docker compose down -v ``` -------------------------------- ### Deploy Application with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-mysql/README.md Commands to build and run the Dockerized application in detached mode. It also shows the output of the build process and container creation. ```shell $ 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 1.13-alpine: Pulling from library/golang ... Successfully built 5f7c899f9b49 Successfully tagged nginx-golang-mysql_proxy:latest WARNING: Image for service proxy was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating nginx-golang-mysql_db_1 ... done Creating nginx-golang-mysql_backend_1 ... done Creating nginx-golang-mysql_proxy_1 ... done ``` -------------------------------- ### ASP.NET Backend Structure (Conceptual) Source: https://github.com/docker/awesome-compose/blob/master/nginx-aspnet-mysql/README.md Illustrates the basic file structure for the ASP.NET backend service, including the Dockerfile, project file, and main program file. ```csharp // backend/Dockerfile // backend/aspnet.csproj // backend/Program.cs ``` -------------------------------- ### Verify Running Containers Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-mysql/README.md Lists the running containers managed by Docker Compose, showing their names, commands, services, status, and exposed ports. ```shell $ 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 nginx-golang-mysql-proxy-1 "/docker-entrypoint.…" proxy running 0.0.0.0:80->80/tcp l_db_1 ``` -------------------------------- ### Flask Server Example Source: https://github.com/docker/awesome-compose/blob/master/nginx-flask-mongo/README.md A basic Python Flask server that connects to MongoDB and returns a greeting. This serves as the backend application in the compose setup. ```python from flask import Flask from pymongo import MongoClient app = Flask(__name__) client = MongoClient('mongo', 27017) @app.route('/') def hello(): db = client.test return 'Hello from the MongoDB client!' if __name__ == "__main__": app.run(host='0.0.0.0', port=5000) ``` -------------------------------- ### Docker Compose WordPress Configuration Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/wordpress/README.md Defines the services for a WordPress blog and a MySQL database, including image versions, volumes for data persistence, environment variables, and network ports. ```yaml services: db: # We use a mariadb image which supports both amd64 & arm64 architecture image: mariadb:10.6.4-focal # If you really want to use MySQL, uncomment the following line #image: mysql:8.0.27 command: '--default-authentication-plugin=mysql_native_password' volumes: - db_data:/var/lib/mysql restart: always environment: - MYSQL_ROOT_PASSWORD=somewordpress - MYSQL_DATABASE=wordpress - MYSQL_USER=wordpress - MYSQL_PASSWORD=wordpress expose: - 3306 - 33060 wordpress: image: wordpress:latest volumes: - wp_data:/var/www/html ports: - 80:80 restart: always environment: - WORDPRESS_DB_HOST=db - WORDPRESS_DB_USER=wordpress - WORDPRESS_DB_PASSWORD=wordpress - WORDPRESS_DB_NAME=wordpress volumes: db_data: wp_data: ``` -------------------------------- ### Deploying the ELK Stack with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/elasticsearch-logstash-kibana/README.md Command to start the Elasticsearch, Logstash, and Kibana services defined in the docker-compose.yaml file in detached mode. ```bash $ docker compose up -d ``` -------------------------------- ### Deploying with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/wasmedge-kafka-mysql/README.md Commands to start the application services defined in the docker-compose.yml file in detached mode and to list the status of the running containers. ```bash $ docker compose up -d ... ⠿ Network wasmedge-kafka-mysql_default Created 0.1s ⠿ Container wasmedge-kafka-mysql-redpanda-1 Created 0.3s ⠿ Container wasmedge-kafka-mysql-etl-1 Created 0.3s ⠿ Container wasmedge-kafka-mysql-db-1 Created 0.3s ``` ```bash $ docker compose ps NAME COMMAND SERVICE STATUS PORTS wasmedge-kafka-mysql-db-1 "docker-entrypoint.s…" db running 3306/tcp wasmedge-kafka-mysql-etl-1 "kafka.wasm" etl running wasmedge-kafka-mysql-redpanda-1 "/entrypoint.sh 'red…" redpanda running 0.0.0.0:8081-8082->8081-8082/tcp, :::8081-8082->8081-8082/tcp, 0.0.0.0:9092->9092/tcp, :::9092->9092/tcp, 0.0.0.0:9644->9644/tcp, :::9644->9644/tcp, 0.0.0.0:29092->29092/tcp, :::29092->29092/tcp ``` -------------------------------- ### Deploying the Docker Compose Stack Source: https://github.com/docker/awesome-compose/blob/master/prometheus-grafana/README.md Command to deploy the Prometheus and Grafana services defined in the docker-compose.yaml file. This command starts the services in detached mode. ```bash $ docker compose up -d Creating network "prometheus-grafana_default" with the default driver Creating volume "prometheus-grafana_prom_data" with default driver ... Creating grafana ... done Creating prometheus ... done Attaching to prometheus, grafana ``` -------------------------------- ### Deploy Django Application Source: https://github.com/docker/awesome-compose/blob/master/django/README.md Commands to deploy the Django application using Docker Compose. This includes building the image, creating and starting the containers in detached mode. ```bash $ docker compose up -d Creating network "django_default" with the default driver Building web Step 1/6 : FROM python:3.7-alpine ... ... Status: Downloaded newer image for python:3.7-alpine Creating django_web_1 ... done ``` -------------------------------- ### Access Application Service Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-mysql/README.md Demonstrates how to access the application's backend service via `localhost:80` using a web browser or `curl`, showing the expected JSON response. ```shell $ curl localhost:80 ["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"] ``` -------------------------------- ### Docker Swarm Deployment Example Source: https://github.com/docker/awesome-compose/blob/master/react-express-mysql/backend/README.md A sample docker-stack.yml file for deploying the Node.js application to Docker Swarm, demonstrating production deployment configurations. ```yaml version: '3.8' services: app: image: your-dockerhub-username/awesome-compose:latest ports: - "3000:3000" environment: NODE_ENV: production deploy: replicas: 3 restart_policy: condition: on-failure networks: - app-network networks: app-network: driver: overlay ``` -------------------------------- ### Deploy Portainer with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/portainer/README.md Command to start the Portainer service in detached mode. Assumes a compose file (e.g., compose.yaml) is present in the current directory. ```shell docker compose up -d ``` -------------------------------- ### Verify Gitea Deployment with Docker PS Source: https://github.com/docker/awesome-compose/blob/master/gitea-postgres/README.md Command to list running Docker containers, verifying that the Gitea and PostgreSQL containers are active and showing the correct port mappings. ```bash $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2f5624043da9 gitea/gitea:latest "/usr/bin/entrypoint…" 56 seconds ago Up 16 seconds 22/tcp, 0.0.0.0:3000->3000/tcp gitea-postgres_gitea_1 86acc768453e postgres:alpine "docker-entrypoint.s…" 57 seconds ago Up 17 seconds 5432/tcp gitea-postgres_db_1 ``` -------------------------------- ### Access Spark Java Application Source: https://github.com/docker/awesome-compose/blob/master/sparkjava/README.md Command to test the Spark Java application by sending an HTTP GET request to the exposed port. It shows the expected response from the application. ```bash $ curl localhost:8080 Hello from Docker! ``` -------------------------------- ### Check Running Services Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-postgres/README.md Command to list the running containers managed by Docker Compose, showing their status and port mappings. ```shell $ 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 nginx-golang-postgres-proxy-1 "/docker-entrypoint.…" proxy running 0.0.0.0:80->80/tcp ``` -------------------------------- ### Access Application via HTTP Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-postgres/README.md Command to fetch data from the application's root endpoint using curl, demonstrating the Go backend's response. ```shell $ curl localhost:80 ["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"] ``` -------------------------------- ### Frontend Dockerfile Source: https://github.com/docker/awesome-compose/blob/master/react-express-mongodb/frontend/README.md This Dockerfile builds the frontend ReactJS application. It uses a Node.js base image, installs dependencies, copies the application code, exposes the application port, and defines the start command. ```dockerfile # Create image based on the official Node image from dockerhub FROM node:10 #Argument that is passed from docer-compose.yaml file ARG FRONT_END_PORT # Create app directory WORKDIR /usr/src/app #Echo the argument to check passed argument loaded here correctly RUN echo "Argument port is : $FRONT_END_PORT" # Copy dependency definitions COPY package.json /usr/src/app # Install dependecies RUN npm install # Get all the code needed to run the app COPY . /usr/src/app # Expose the port the app runs in EXPOSE ${FRONT_END_PORT} # Serve the app CMD ["npm", "start"] ``` -------------------------------- ### View Running Containers Source: https://github.com/docker/awesome-compose/blob/master/react-rust-postgres/readme.md Command to list all running containers, showing their IDs, images, commands, status, ports, and names. Useful for verifying the deployment. ```bash $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 30b7d9dc4898 react-rust-postgres_backend "cargo run --offline" 37 seconds ago Up 35 seconds 8000/tcp react-rust-postgres_backend_1 0bca0cb682b8 react-rust-postgres_frontend "docker-entrypoint.s…" 42 seconds ago Up 41 seconds 0.0.0.0:3000->3000/tcp react-rust-postgres_frontend_1 1611961bf3d1 postgres:12-alpine "docker-entrypoint.s…" 42 seconds ago Up 36 seconds 0.0.0.0:5432->5432/tcp react-rust-postgres_db_1 ``` -------------------------------- ### Go Backend Service (Conceptual) Source: https://github.com/docker/awesome-compose/blob/master/nginx-golang-mysql/README.md A conceptual Go program that would run as the backend service. It's assumed to listen on a port (e.g., 8080) and serve data. ```go package main import ( "encoding/json" "fmt" "log" "net/http" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { posts := []string{ "Blog post #0", "Blog post #1", "Blog post #2", "Blog post #3", "Blog post #4", } w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(posts) if err != nil { log.Printf("Error encoding JSON: %v", err) http.Error(w, "Internal Server Error", http.StatusInternalServerError) } }) fmt.Println("Server starting on port 8080...") log.Fatal(http.ListenAndServe(":8080", nil)) } ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/docker/awesome-compose/blob/master/react-rust-postgres/readme.md Defines the services for the React frontend, Rust backend, and PostgreSQL database. It specifies build contexts, images, and port mappings. ```yaml services: backend: build: backend ... db: image: postgres:12-alpine ... frontend: build: frontend ports: - 3000:3000 ... ``` -------------------------------- ### Checking Running Containers Source: https://github.com/docker/awesome-compose/blob/master/nginx-aspnet-mysql/README.md Command to list all running Docker containers, showing their IDs, images, commands, status, ports, and names. Useful for verifying the deployment. ```bash $ docker ps ``` -------------------------------- ### Django ALLOWED_HOSTS Configuration Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/django/README.md This Python code snippet demonstrates how to configure the ALLOWED_HOSTS setting in Django's settings.py. The example shows setting it to '*' for demo purposes, which allows all host headers. It also includes a note about this not being safe for production and links to Django documentation for proper configuration. ```python ALLOWED_HOSTS = ['*'] ``` -------------------------------- ### Installing Packages in a Running Container Source: https://github.com/docker/awesome-compose/blob/master/react-express-mysql/backend/README.md Demonstrates how to install new npm packages into a running Node.js container managed by Docker Compose. The command executes `npm install` inside the 'node' service container, and nodemon will automatically restart the application. ```bash docker-compose exec node npm install --save ``` -------------------------------- ### Django App with Docker Compose Source: https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/README.md Demonstrates setting up and running a simple Django application with PostgreSQL using Docker Compose. This sample helps understand service definitions and inter-service communication within a Compose environment. ```yaml version: "3.8" services: web: build: . command: python /code/manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" depends_on: - db db: image: postgres:13 volumes: - postgres_data:/var/lib/postgresql/data/ volumes: postgres_data: ``` -------------------------------- ### Plex Docker Compose Configuration Source: https://github.com/docker/awesome-compose/blob/master/plex/README.md Defines the Plex service using the linuxserver/plex image within a Docker Compose setup. It specifies the image to be used for the Plex container. ```yaml services: plex: image: linuxserver/plex:latest ``` -------------------------------- ### Dockerfile for FastAPI Application Source: https://github.com/docker/awesome-compose/blob/master/fastapi/requirements.txt This Dockerfile outlines the steps to build a Docker image for a FastAPI application. It installs Python, copies the application code, installs dependencies, and sets the command to run the application with Uvicorn. ```dockerfile FROM python:3.9-slim WORKDIR /app COPY requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] ```