vultr 主机推荐
Share Your Link: https://www.vultr.com/?ref=6851639 Give $100, Get $35: https://www.vultr.com/?ref=8955885-8H
安装Docker 环境
apt-get -y update;apt-get -y upgrade sudo curl -sS https://get.docker.com/ | sh sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose docker-compose --version
生成需要的文件
mkdir -p helloworld/{conf.d,logs,app}
cat >helloworld/conf.d/nginx.conf <<EOG
server {
listen 8888;
location / {
default_type text/html;
contentbylua_file "/app/app.lua";
}
}
EOG
cat >helloworld/app/app.lua <<EOG
ngx.say('Hello World! from: QQqun: 397745473')
ngx.exit(200)
EOG
# cd helloworld && docker build -t vsyour/helloworld .
# docker push vsyour/helloworld
启动访问
# docker run -it -d --name helloworld -p 8080:8080 -v $(pwd):/app vsyour/helloworld
cat >helloworld/docker-compose.yml <<EOG
version: '3'
services:
openresty:
container_name: helloworld
image: openresty/openresty:alpine
restart: always
tty: true
volumes:
- ./app:/app
- ./logs:/usr/local/openresty/nginx/logs
- ./conf.d/:/etc/nginx/conf.d
ports:
- "8888:8888"
networks:
- appnet
networks:
appnet:
EOG
cd helloworld && docker-compose up -d
访问: http://ip:8888

浙公网安备 33010602011771号