COMPOSE (from an .yml file)

The Docker Compose functionality is a mere automatization process improving readability and effeciency.

A sample docker-compose.yml:

version: "3.6"

services:

  db:
      image: jorgenlarsen/mariadb10.3:rpi
      volumes:
         - db-data:/var/lib/mysql/data 
      restart: always
      environment:
         MYSQL_ROOT_PASSWORD: root
         MYSQL_DATABASE: wordpress
         MYSQL_USER: wordpress
         MYSQL_PASSWORD: root
      ports:
        - '3306:3306'
      networks:
         - overlay
      deploy:
        mode: replicated
        replicas: 4
        endpoint_mode: vip

  wordpress:
      depends_on:
        - db
      image: arm32v7/wordpress
      ports:
        - "8000:80"
      restart: always
      environment:
        WORDPRESS_DB_HOST: db:3306
        WORDPRESS_DB_USER: wordpress
        WORDPRESS_DB_PASSWORD: root
      networks:
        - overlay
      deploy:
        mode: replicated
        replicas: 4
        endpoint_mode: vip
  
# phpmyadmin
  phpmyadmin:
      depends_on:
        - db
      image: arm32v7/phpmyadmin
      restart: always
      ports:
        - "8080:80"
      environment:
        PMA_HOST: db
        MYSQL_ROOT_PASSWORD: root
      networks:
        - overlay
      deploy:
        mode: replicated
        replicas: 4
        endpoint_mode: vip
  
volumes:
  db-data:

networks:
  overlay:

Processing above takes place:

$ sudo mkdir mariaDB10.3
$ sudo cd mariaDB10.3

Copy above text to the file: docker-compose.yml

$ sudo apt install docker-compose

$ docker-compose up -d
WARNING: Some services (db, phpmyadmin, wordpress) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

Pulling wordpress (arm32v7/wordpress:)...
latest: Pulling from arm32v7/wordpress
d6d8411ad43d: Pull complete
538673f8bb90: Pull complete
f6a77ccf6376: Pull complete
15d118c7f7da: Pull complete
9d1b918607ea: Pull complete
52a666736c68: Pull complete
cedabb113cc2: Pull complete
5d10f1059dab: Pull complete
5b65977f7ae2: Pull complete
202aaed016bc: Pull complete
0100cc21d1e0: Pull complete
c0a4101d61d1: Pull complete
b5b53d5f77cb: Pull complete
f8795a2d2736: Pull complete
e195268ccbd6: Pull complete
82b7c7dacba2: Pull complete
f4c0fb377724: Pull complete
39f5a8ab9a78: Pull complete
51f070f75a68: Pull complete
6cd000595a4b: Pull complete
Digest: sha256:b09afac439b02941649dc198f857720951ab5e4f665b063614720c3aad04b762
Status: Downloaded newer image for arm32v7/wordpress:latest
Pulling phpmyadmin (arm32v7/phpmyadmin:)...
latest: Pulling from arm32v7/phpmyadmin
d6d8411ad43d: Already exists
538673f8bb90: Already exists
f6a77ccf6376: Already exists
15d118c7f7da: Already exists
9d1b918607ea: Already exists
52a666736c68: Already exists
cedabb113cc2: Already exists
5d10f1059dab: Already exists
5b65977f7ae2: Already exists
202aaed016bc: Already exists
0100cc21d1e0: Already exists
c0a4101d61d1: Already exists
b5b53d5f77cb: Already exists
879a73ad66b0: Pull complete
7afcc7c52f2c: Pull complete
74bbea5c70d9: Pull complete
63da607ea722: Pull complete
e569098bc833: Pull complete
Digest: sha256:1a638729328f3dfe5b50a5cfe76af5ef479412fa38f3c8f2cd5a12c4c7e6ca88
Status: Downloaded newer image for arm32v7/phpmyadmin:latest


Starting supercomputermariadb_db_1 ... done
Creating supercomputermariadb_wordpress_1  ... done
Creating supercomputermariadb_phpmyadmin_1 ... done

Use Portainer to see the Graphical representation of:

  • Containers
  • Network

generated.

The official link:

https://docs.docker.com/compose/

https://docs.docker.com/compose/compose-file/

Leave a Reply

Your email address will not be published. Required fields are marked *