Facebook
From Blush Plover, 2 Years ago, written in Plain Text.
This paste is a reply to Re: dockercompose from Round Matamata - view diff
Embed
Download Paste or View Raw
Hits: 131
  1. In docker-compose.yml: (Infrastructure Code)
  2. ----------------------------------------------
  3. version: '3'
  4.  
  5. services:
  6.   dbos:
  7.     image: mysql:5.7
  8.     volumes: (This Will Mount the Volume)
  9.           - mysql_storage_new:/var/lib/mysql
  10.     restart: always
  11.     envirnoment:
  12.           MYSQL_USER: vimal
  13.           MYSQL_ROOT_PASSWORD: rootpass
  14.           MYSQL_PASSWORD: redhat
  15.           MYSQL_DATABASE: mydb
  16.  
  17.   wpos:
  18.     image: wordpress:5.1.1-php7.3-apache
  19.     volumes: (This Will Mount the Volume)
  20.           - wp_storage_new:/var/www/html
  21.     restart: always
  22.     depends_on:
  23.           - dbos
  24.     ports:
  25.           - 8081:80
  26.     environment:
  27.           WORDPRESS_DB_HOST: dbos
  28.           WORDPRESS_DB_USER: vimal
  29.           WORDPRESS_DB_PASSWORD: redhat
  30.           WORDPRESS_DB_NAME: mydb
  31.  
  32. volumes: (This Will Create the Volumes)
  33.   wp_storage_new:
  34.   mysql_storage_new:
  35. ----------------------------------------------
  36. Here,
  37. version: '3' mean we need to specify which docker-compose version we are using.
  38. services: is used to launch the containers.
  39. dbos is the name of the container.
  40. image key has single value mysql:5.7
  41. volumes key is kind of list in here so we use hyphen "-" . There will be no space after ":" in mysql_storage_new:/var/lib/mysql , Here "volumes' is used to mount the location.
  42. restart key has the value always which mean this container will always start in background when we run docker-compose.
  43. environment key has block of Statements so we use Indent here.
  44. depends_on key creates the link with wpos to dbos.
  45. ports key do the PAT to 8081 to 80. or we can say expose the 80 port to outside world using 8081 port no.
  46. volumes key is used to create the storage so that services can mount the storage locations.