Docker 基于 Centos8 安装环境
1、仅安装 centos8
vi docker-compose.yml
version: "3"
services:
centos8:
build:
context: ./
dockerfile: Dockerfile
hostname: centos8
container_name: centos8
stdin_open: true
tty: true
vi Dockerfile
FROM centos:8
docker-compose up -d
docker ps 就可以看到 centos8 的容器了
2、安装 WEB 环境
安装 Nginx
修改 docker-compose.yml, vi docker-compose.yml
# 新增对外暴漏端口
ports:
- "80:80"
- "443:443"
volumes:
# Nginx 相关挂载目录
- ./wwwroot:/wwwroot:rw
- ./services/nginx/nginx.conf:/usr/local/nginx/conf/nginx.conf:rw
- ./services/nginx/certs:/usr/local/nginx/conf/certs:rw
- ./services/nginx/conf.d:/usr/local/nginx/conf/conf.d:rw
- ./services/nginx/logs:/usr/local/nginx/logs:rw
修改 Dockerfile, vi Dockerfile
# 安装 Nginx 服务
RUN yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel wget make \
&& cd ~ \
&& wget -c https://nginx.org/download/nginx-1.18.0.tar.gz \
&& tar -zxvf nginx-1.18.0.tar.gz \
&& cd ~/nginx-1.18.0 \
&& ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_sub_module --with-http_gzip_static_module --with-pcre \
&& make && make install \
&& ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/
安装 MySQL
修改 docker-compose.yml, vi docker-compose.yml