# 搜寻nginx镜像
docker search nginx
# 拉取nginx镜像
docker pull nginx
# 查看所有镜像
docker images
# 运行nginx容器,-d 后盾运行容器并打印出容器ID,-p 将容器的80端口映射到主机的3344端口
docker run -d -p 3344:80 --name nginx01 nginx
在浏览器中拜访并显示 Nginx 的默认页:
http://localhost:3344
在开发者工具中能够看到:
Status Code: 304 Not Modified
Remote Address: [::1]:80
查看所有运行中的容器:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8a47e6646e26 nginx "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp nginx01
curl测试:
curl localhost:3344
进入容器:
docker exec -it nginx01 /bin/bash
exit
通过容器名称进行容器:
docker container stop nginx01
通过容器名称移除容器:
docker container rm nginx01 laughing_kowalevski relaxed_sammet
发表回复