Docker 安装Nginx
1、搜索镜像
# 1、搜索镜像
[root@kuangshen ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL
nginx Official build of Nginx. 13159 [OK]
2、拉取镜像
[root@kuangshen ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
54fec2fa59d0: Pull complete
4ede6f09aefe: Pull complete
f9dc69acb465: Pull complete
Digest: sha256:86ae264c3f4acb99b2dee4d0098c40cb8c46dcf9e1148f05d3a51c4df6758c12
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
3、启动容器
[root@kuangshen ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
diytomcat latest ffdf6529937d 3 hours ago 636MB
nginx latest 602e111c06b6 2 weeks ago 127MB
centos latest 470671670cac 3 months ago 237MB
[root@kuangshen ~]# docker run -d --name mynginx -p 3500:80 nginx
a95d5f2f057fc609082cfa0de906bd690f95c43a26d38420d081f0e255b232ec
[root@kuangshen ~]# docker ps
CONTAINER ID IMAGE PORTS NAMES
a95d5f2f057f nginx 0.0.0.0:3500->80/tcp mynginx
4、测试访问
[root@kuangshen ~]# curl localhost:3500
<html>
<title>Welcome to nginx!</title> # ok ....
</html>
5、进入容器
[root@kuangshen ~]# docker exec -it mynginx /bin/bash
root@a95d5f2f057f:/# whereis nginx # 寻找nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@a95d5f2f057f:/# cd /usr/share/nginx # nginx 的路径 root@a95d5f2f057f:/usr/share/nginx# ls
html
root@a95d5f2f057f:/usr/share/nginx/html# cat index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style> body {width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style>
</head>
<body>
<h1>Welcome to nginx!</h1>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/76914.html