docker-镜像(5)

docker 安装 Nginx

#1、搜索镜像  search 建议大家去docker 搜索,可以看到帮助文档信息
#2、下载镜像 pull 
#3、运行测试 

[root@iZ2zee6mimrb4m36ksxoz9Z ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB
centos       latest    300e315adb2f   4 months ago   209MB
# -d 后台运行
# --name 给容器命名
#  -p  宿主机端口:容器内部端口
[root@iZ2zee6mimrb4m36ksxoz9Z ~]# docker run -d --name naginx01 -p 3344:80 nginx
28a9bca8939f65632c4a9ac9b95aef968a6564b1ba601e2ab80579072710d13c
[root@iZ2zee6mimrb4m36ksxoz9Z ~]# docker ps 
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS              
NAMES28a9bca8939f   nginx     "/docker-entrypoint.…"   11 seconds ago   Up 10 seconds   0.0.0.0:3344->80/tc
p   naginx01
[root@iZ2zee6mimrb4m36ksxoz9Z ~]# curl localhost:3344


#进入容器
[root@iZ2zee6mimrb4m36ksxoz9Z ~]# docker exec -it naginx01 /bin/bash
root@28a9bca8939f:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@28a9bca8939f:/# cd  /etc/n
nginx/         nsswitch.conf  
root@28a9bca8939f:/# cd  /etc/nginx/
root@28a9bca8939f:/etc/nginx# ls
conf.d		koi-utf  mime.types  nginx.conf   uwsgi_params
fastcgi_params	koi-win  modules     scgi_params  win-utf
root@28a9bca8939f:/etc/nginx# 

端口暴露的概念

image

posted @ 2021-08-05 20:32  咸鱼豆腐  阅读(40)  评论(0编辑  收藏  举报