docker search nginx
docker pull nginx
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 4f380adfc10f 13 days ago 133MB
docker run -d --name nginx01 -p 80:80 nginx
# 参数解释
# -d 后台运行
# --name给容器重命名
# -p 宿主机端口:容器内部端口
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62c9a70b60fa nginx "/docker-entrypoint.…" 12 seconds ago Up 10 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp nginx01
curl localhost:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
docker exec -it nginx01 /bin/bash
root@62c9a70b60fa:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
原文:https://www.cnblogs.com/simple-record/p/14978560.html