
root@ubuntu:/docker# mkdir regi
root@ubuntu:/docker# cd regi
root@ubuntu:/docker/regi# vi Dockerfile
FROM nginx
root@ubuntu:/docker/regi# docker build --tag localhost:5000/my_nginx:1.0
root@ubuntu:/regi# docker build --tag localhost:5000/my_nginx:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM nginx
latest: Pulling from library/nginx
025c56f98b67: Pull complete
ca9c7f45d396: Pull complete
ed6bd111fc08: Pull complete ㅓ
e25b13a5f70d: Pull complete
9bbabac55ab6: Pull complete
e5c9ba265ded: Pull complete
Digest: sha256:ab589a3c466e347b1c0573be23356676df90cd7ce2dbf6ec332a5f0a8b5e59db
Status: Downloaded newer image for nginx:latest
---> ac8efec875ce
Successfully built ac8efec875ce
Successfully tagged localhost:5000/my_nginx:1.0
root@ubuntu:/docker/regi# docker image ls
root@ubuntu:/regi# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat 1.0 130f69bcd9a1 36 minutes ago 750MB
nginx latest ac8efec875ce 20 hours ago 142MB
localhost:5000/my_nginx 1.0 ac8efec875ce 20 hours ago 142MB
centos 7 eeb6ee3f44bd 14 months ago 204MB
root@ubuntu:/docker/regi# docker run -dp 5000:5000 --name pregistry registry
registry image로 container를 생성하면 그 container는 내 private repository가 된다(개인 Docker hub)로 보면 됨).
-dp 5000:5000에서 뒤의 5000은 registry image의 well-known port이다.
즉 앞의 5000은 임의로 정한 포트 번호고, 뒤의 5000은 registry의 well-known port다.
root@ubuntu:/docker/regi# docker push localhost:5000/my_nginx:1.0
이름을 localhost:5000로 맞춰줘야 됨 (Github의 그것과 비슷하다.)
localhost:5000은 Github의 사용자명에 대응되고, my_nginx:1.0은 Github의 repository 이름에 대응된다.
root@ubuntu:/docker/regi# docker run -dp 777:80 --name my_nginx localhost:5000/my_nginx:1.0
root@ubuntu:/docker/regi# curl localhost:777
root@ubuntu:/docker/regi# curl localhost:777
<!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>