1、下载最新版nginx
```$ docker pull ngnix
[root@tome ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
b4d181a07f80: Pull complete
edb81c9bc1f5: Pull complete
b21fed559b9f: Pull complete
03e6a2452751: Pull complete
b82f7f888feb: Pull complete
5430e98eba64: Pull complete
Digest: sha256:47ae43cdfc7064d28800bc42e79a429540c7c80168e8c8952778c0d5af1c09db
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
2、查询是否安装成功
docker images
[root@tome ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4f380adfc10f 11 days ago 133MB
3、后台启动Nginx
docker run -d --name nginx01 -p 3344:80 nginx
[root@tome ~]# docker run -d --name nginx01 -p 3344:80 nginx
00c01a7fd3001435f104e89c017efa5a6bab5a46bfdaebef11d562600ef738fb
注释说明:
–name 给容器命令
-d 后台运行
-p 宿主机端口、容器内部端口
4、进入容器中
docker exec -it nginx02 /bin/bash
[root@tome ~]# docker exec -it nginx02 /bin/bash
root@6ae6bdd6a696:/#
root@6ae6bdd6a696:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@6ae6bdd6a696:/# cd /etc/nginx
root@6ae6bdd6a696:/etc/nginx# ls
conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params