部署環境
1、C槽建立記事本dockerfile,輸入内容
FROM nginx
MAINTAINER 姓名
RUN echo "Hi, This Is A Docker Continer Website" > /usr/share/nginx/html/index.html EXPOSE 80
2、建構:docker build -t nginx_web -f Dockerfile
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL0IDOwEzM4kTOx0CM2MzMyIDMzIDOyITMxIDMy0yM5MzM3YjMvwlMxEjMwIzLcNTOzMzN2IzLcd2bsJ2Lc12bj5ycn9Gbi52YuAjMwIzZtl2Lc9CX6MHc0RHaiojIsJye.png)
3、運作鏡像:docker --rm -p80:80 nginx_web
檢視nginx服務的日志資訊:docker logs -f 容器ID
80:web預設端口
443:安全協定
25:郵件服務
22:ssh服務端口
部署python環境
1、C槽建立dockerfile,輸入:
FROM centos:7.8.2003
#下載下傳yum
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo;
RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo;
#安裝Python環境
RUN yum install python3-devel python3-pip -y
#安裝flask庫
RUN pip3 install -i https://pypi.douban.com/simple flask
RUN pip3 install flask_restful
RUN pip3 install flask_httpauth
RUN pip3 install flask_jwt
#複制檔案到容器目錄
COPY app.py /opt
#切換目錄
WORKDIR /opt
#啟動服務
EXPOSE 5000
CMD ["python3","app.py"]
2、建構:docker build -t python_web -f Dockerfile .
3、運作鏡像:docker run --rm -p5000:5000 python_web #運作鏡像資訊
4、依據IP位址打開浏覽器輸入資訊
查詢ip位址(ipv4):ipconfig
netstat -ano | findstr "被查詢的端口" #根據端口查詢到應用程式的pid資訊
tasklist | findstr "pid" #根據pid資訊查詢到具體的應用程式
使用Docker來安裝RabbitMQ
MQ:生産者消費者模式
MQ:kafka,rabbitmq,activitymq
1、輸入:docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:latest
2、建立背景運作,輸入docker ps -a
3、docker port ID(rabbitmq的ID)
4、浏覽器中輸入http://localhost:15672/,賬号密碼統一輸入guest,點選回車