In docker-compose.yml: (Infrastructure Code)
----------------------------------------------
version: '3'
services:
dbos:
image: mysql:5.7
volumes: (This Will Mount the Volume)
- mysql_storage_new:/var/lib/mysql
restart: always
envirnoment:
MYSQL_USER: vimal
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_PASSWORD: redhat
MYSQL_DATABASE: mydb
wpos:
image: wordpress:5.1.1-php7.3-apache
volumes: (This Will Mount the Volume)
- wp_storage_new:/var/www/html
restart: always
depends_on:
- dbos
ports:
- 8081:80
environment:
WORDPRESS_DB_HOST: dbos
WORDPRESS_DB_USER: vimal
WORDPRESS_DB_PASSWORD: redhat
WORDPRESS_DB_NAME: mydb
volumes: (This Will Create the Volumes)
wp_storage_new:
mysql_storage_new:
----------------------------------------------
Here,
version: '3' mean we need to specify which docker-compose version we are using.
services: is used to launch the containers.
dbos is the name of the container.
image key has single value mysql:5.7
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.
restart key has the value always which mean this container will always start in background when we run docker-compose.
environment key has block of Statements so we use Indent here.
depends_on key creates the link with wpos to dbos.
ports key do the PAT to 8081 to 80. or we can say expose the 80 port to outside world using 8081 port no.
volumes key is used to create the storage so that services can mount the storage locations.
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}