在阿里云ECS上安装docker、docker-compose并用docker容器启动nginx。
安装docker
官方文档参考https://docs.docker.com/engine/install/ubuntu/。 Step by step操作就行。
安装docker-compose
官方文档参考https://docs.docker.com/compose/install/。
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
但是,国内拉得好慢!拉了一半,断了。网搜一可用命令:
sudo curl -L "https://get.daocloud.io/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
可以看到版本号就O了。
配置docker-compose.yml
cd /opt/data/
web:
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
-
ports:
- "8080:80"
environment:
- NGINX_HOST=foobar.com
- NGINX_PORT=80
nginx.conf
events {
}
http {
include /usr/local/etc/nginx/mime.types;
server {
listen 80;
server_name localhost;
client_max_body_size 10m;
location / {
alias /opt/data/helloworld/;
index index.html;
}
}
}
|