docker-compose.yml files to the top-level directory under nodeapp Operations File operations
vi docker-compose.yml
As follows:
// can not use the name of the mirror needs to compile the package node in the document images files to build
container // depends_on dependent
Version: "2"
Services:
db:
Image: MariaDB
Environment:
MYSQL_ROOT_PASSWORD: "123456"
MYSQL_DATABASE: "nodeapp"
mysql_user: "guozimo"
MYSQL_PASSWORD: "123456"
Volumes:
- the dbdata: / var / lib / MySQL
Node:
Build:
context: "./images/node"
dockerfile: Dockerfile
depends_on:
- DB
Web:
Image: Nginx
the ports :
- "8080: 80"
depends_on:
- node
volumes:
- "./images/nginx/conf.d:/etc/nginx/conf.d"
- "./images/node/web/public:/public"
volumes:
dbdata:
driver: local
////////
vi default.conf
Here's what default.conf of
processing dynamic file static files
curl http://127.0.0.1:3000
server{
listen 80;
server_name localhost 39.105.91.188;
location /{
root /public;
index index.html;
}
location /api{
proxy_pass http://127.0.0.1:3000
}
}
docker-compose up
comments in the code:
/ **
** /
let http =require("http");
http.createServer(function(req,res){
res.end("3000");
}).listen(3000,function(){
console.log('node server start at port 3000')
});
Compose Down-Docker
Docker Compose-up --build
after // modify the code needs to be recompiled to recompile node Mirror
Turn off the firewall
systemctl STOP firewalld.service
systemctl firewalld.service disable
firewall restart
systemctl restart docker
server{
listen 80;
server_name localhost 39.105.91.188;
location /{
root /public;
index index.html;
}
location /api{
proxy_pass http://node:3000;
}
}
Root access:
curl HTTP: // localhost: 8080 / API
Continue to modify server.js
echo index.html> index.html
[root @ guozimo public] # echo 404.html> 404.html
If docker-compose up --build
access curl http: // locahost: 8080 / api database access error
you can try to update the look
Docker pull MySQL
Docker pull MariaDB
re docker-compose up --build
revisit curl http: // locahost: 8080 / api