Docker+Nginx

Dokcer 安装Nginx

#1 搜索镜像

#2 下载镜像 pull 

#3 运行测试
[root@root /]# docker run -d --name nginx01 -p 8848:80 nginx
6115324a076dd922b8e7487603430bfdcc5179aae68423bcfe5584588709a995

[root@root /]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                  NAMES
6115324a076d        nginx               "/docker-entrypoint.…"   About a minute ago   Up About a minute   0.0.0.0:8848->80/tcp   nginx01

[root@root /]# curl localhost:8848
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>

#进入容器
[root@root /]# docker exec -it nginx01 /bin/bash
root@6115324a076d:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@6115324a076d:/# cd /etc/nginx
root@6115324a076d:/etc/nginx# ls
conf.d	fastcgi_params	koi-utf  koi-win  mime.types  modules  nginx.conf  scgi_params	uwsgi_params  win-utf
root@6115324a076d:/etc/nginx#

思考:每次改动nginx配置文件,都需要进入容器内部?十分麻烦,我要是可以在容器外部提供一个映射路径,达到在容器修改文件名,容器内部就可以自动修改? -v 数据卷!

posted @ 2020-07-08 19:30  CosmosRay  阅读(164)  评论(0编辑  收藏  举报