In my previous post we learned how to Dockerize a Ghost Platform and persistent data in docker host. Now we go further and connect our Ghost platform to MYSQL database and save our data in a data container . I'm using docker-compose tool to make things simpler . ( I'm using Debian 8 "jessie" 192.168.0.100 )
Step 1 : Installing docker-compose :
Step 1 : Installing docker-compose :
apt-get -y install python-pip
pip install docker-compose
Step 2 : Creating Folder and YAML file for docker-compose processing . we need to create file docker-compose.yaml . Ive created 3 containers . my_data is for persisting data , my_mysql that is our ghost platform database and my_ghostblog . I passed my config.js file to my_ghostblog .
mkdir /usr/src/ghost-docker/
cd /usr/src/ghost-docker/
vim docker-compose.yaml
my_data:
image: busybox
container_name: "my_data"
volumes:
- /var/lib/mysql
- /var/lib/ghost/
- /var/lib/ghost/apps/
- /var/lib/ghost/data/
- /var/lib/ghost/themes/
- /var/lib/ghost/images/
my_mysql:
image: mysql
container_name: "my_mysql"
volumes_from:
- my_data
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=ghost
- MYSQL_USER=ghost
- MYSQL_PASSWORD=omidreza
expose:
- "3306"
my_ghostblog:
image: ghost
container_name: "my_ghostblog"
volumes:
- ./config.js:/var/lib/ghost/config.js
volumes_from:
- my_data
environment :
- URL=http://192.168.0.100
- NODE_ENV=production
links:
- my_mysql:mysql
ports:
- "80:2368"
Step 3 : Defining database in Ghost platform config.js file .
production: {
url: 'http://192.168.0.100',
mail: {},
database: {
client: 'mysql',
connection: {
host : 'my_mysql',
user : 'ghost',
password : 'omidreza',
database : 'ghost',
charset : 'utf8'
}
},
server: {
host: '0.0.0.0',
port: '2368'
},
paths: {
contentPath: path.join(__dirname, '/')
}
},
Step 4 : Creating and running our containers using docker-compose
docker-compose up -d
Comments
Post a Comment