nginx의 최신 버전 이미지로 컨테이너를 생성하라. 단, 컨테이너의 이름은 nginx이고 background 상태여야 한다. 또한 해당 컨테이너의 IP 주소를 통해 동작 여부를 확인하라.
root@ubuntu:~# docker run --name nginx -d nginx:latest
root@ubuntu:~# docker run --name nginx -d nginx:latest
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
a603fa5e3b41: Already exists
c39e1cda007e: Pull complete
90cfefba34d7: Pull complete
a38226fb7aba: Pull complete
62583498bae6: Pull complete
9802a2cfdb8d: Pull complete
Digest: sha256:e209ac2f37c70c1e0e9873a5f7231e91dcd83fdf1178d8ed36c2ec09974210ba
Status: Downloaded newer image for nginx:latest
81d04c495f7c937c9983ec45af7e41d6eeb08dbbec5923253d95258449c945a0
사실 docker pull image nginx
로 먼저 땡겨오는 게 정석이다.
root@ubuntu:~# docker ps -a
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
81d04c495f7c nginx:latest "/docker-entrypoint.…" 15 seconds ago **Up 14 seconds** 80/tcp nginx
root@ubuntu:~# docker inspect nginx
...
"Gateway": "172.17.0.1",
**"IPAddress": "172.17.0.2",**
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
...
또는 다음과 같이 확인한다.
root@ubuntu:~# curl 172.17.0.2
root@ubuntu:~# curl 172.17.0.2
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
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>