Docker 安装Nginx
1、搜索镜像
[root@kuangshen ~]
NAME DESCRIPTION STARS OFFICIAL
nginx Official build of Nginx. 13159 [OK]
2、拉取镜像
[root@kuangshen ~]
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 ~]
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 ~]
a95d5f2f057fc609082cfa0de906bd690f95c43a26d38420d081f0e255b232ec
[root@kuangshen ~]
CONTAINER ID IMAGE PORTS NAMES
a95d5f2f057f nginx 0.0.0.0:3500->80/tcp mynginx
4、测试访问
[root@kuangshen ~]
<html>
<title>Welcome to nginx!</title>
</html>
5、进入容器
[root@kuangshen ~]
root@a95d5f2f057f:/
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@a95d5f2f057f:/
html
root@a95d5f2f057f:/usr/share/nginx/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>