nisham22
12/8/2017 - 6:25 AM

Docker Compose

YAML file referring networking

mysqldb:
  container_name: "db"
  image:mysql
  enviroment:
    - MYSQL_DATABASE: sample
    - MYSQL_USER: mysql
    - MYSQL_PASSWORD: mysql
    - MYSQL_ROOT_PASSWORD: secret
mywildfly:
  image: arungupta/wildfly-mysql-javaee7
  enviroment:
    - MYSQL_URI=db:3306 (Port is defined here)
  ports:
    - 8080:8080

Link Container :

Mysql with env variables

docker run
--name mysql-db
-e MYSQL_USER=mysql
-e MYSQL_PASSWORD=mysql
-e MYSQL_DATABASE=sample
-e MYSQL_ROOT_PASSWORD=secret
-d
mysql

Wildfly run command

docker run
--name mywildfly
--link mysqldb:db
-p 8080:8080
-d
arungupta/wildfly-mysql-javaee7

New docker-compose.yml With linking Wildfly with Mysql

mysqldb:
  image:mysql
  enviroment:
    - MYSQL_DATABASE: sample
    - MYSQL_USER: mysql
    - MYSQL_PASSWORD: mysql
    - MYSQL_ROOT_PASSWORD: secret
mywildfly:
  image: arungupta/wildfly-mysql-javaee7
  links:
    - mysqldb:db

Conatiner Volume

When a Container is created and stopped, data related to that container will be destroyed

In that case we use volume mapping CLI command :

docker run -d -p 8080:80 -v local_path_to_mooshak_data:/home/mooshak/data ruippeixotog/mooshak

YAML file

couchbase1:
  image: couchbase/server
  volumes:
    - ~/couchbase/node1:/home/user/nisham
couchbase2:
  image: couchbase/server
  volumes:
    - ~/couchbase/node2:/home/user/nisham   
ports:
  - 8091:8091
  - 8092:8092
  - 8093:8093

To start docker compose

sudo docker-compose up

To List docker-compose

sudo docker-compose ps

Run Docker compose on Background

sudo docker-compose up -d

YAML file

version: '3'
services:
   emanback:
     image: docker-emanbackend 
     ports:
      - "6070:5050"
   emanui: 
     image: docker-emanui
     ports:
      - "3033:3000"