linux配置docker-compose_Nginx
1.拉取镜像
docker pull nginx:latest
2.查看镜像版本
docker image inspect nginx:latest|grep -i version #18.09.07
3.配置docker-compose
version: "3.2" services: nginx_web: restart: always container_name: nginx_web image: nginx:latest ports: - 80:80 networks: - master networks: master: external: true
4.查看容器
docker ps -a
5.进入容器
docker exec -it nginx_web /bin/bash
6.将nginx.conf的配置文件拷贝出来
/etc/nginx/nginx.conf
7.节点配置
如 :nginx:latest>>V.18.09.07
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
8.重新加载docker-compose
version: "3.2"
services:
nginx_web:
restart: always
container_name: nginx_web
image: nginx:latest
volumes:
- /home/API/nginx_web:/usr/share/nginx/html
- /home/API/nginx_web/config/nginx.conf:/etc/nginx/nginx.conf
#- /home/API/nginx_web/logs:/var/log/nginx
ports:
- 80:80
networks:
- master
networks:
master:
external: true