安装
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sh get-docker.sh
$ docker ps # 说明安装成功并已运行
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
运行nginx容器
先在ECS控制台上允许80端口的访问,然后拉取nginx镜像,运行一个nginx容器,从本地访问该容器服务.
$ docker pull nginx
$ docker run -d -p 80:80 nginx
c876b8130b0833ba98e9e0a0960ffe6dca4b18ec5d0ab1b6cab29dc26acac39a
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c876b8130b08 nginx "/docker-entrypoint.…" 16 seconds ago Up 15 seconds 0.0.0.0:80->80/tcp confident_euclid
验证服务
$ curl 39.97.xx.xx # ECS IP
<!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>