1、下載下傳最新版nginx
```$ docker pull ngnix
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# docker run -d --name nginx01 -p 3344:80 nginx
00c01a7fd3001435f104e89c017efa5a6bab5a46bfdaebef11d562600ef738fb
注釋說明:
–name 給容器指令
-d 背景運作
-p 主控端端口、容器内部端口
4、進入容器中
docker exec -it nginx02 /bin/bash
[[email protected] ~]# docker exec -it nginx02 /bin/bash
[email protected]:/#
[email protected]:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
[email protected]:/# cd /etc/nginx
[email protected]:/etc/nginx# ls
conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params