一.发布自己的项目

DockerHub

  1. 地址:https://hub.docker.com/ 注册自己的账号
  2. 确定账号可以登录
  3. 登录完毕后就可以提交镜像,就是一步 docker push ```shell

[root@localhost mytomcat]# docker login —help Usage: docker login [OPTIONS] [SERVER] Log in to a Docker registry. If no server is specified, the default is defined by the daemon. Options: -p, —password string Password —password-stdin Take the password from stdin -u, —username string Username

登录

[root@localhost mytomcat]# docker login -u xiaohuyyds Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

  1. 4. 在我们的服务器上提交自己的镜像
  2. ```shell
  3. # 登录完毕后就可以提交镜像,就是一步 docker push
  4. [root@localhost mytomcat]# docker push diytomcat
  5. Using default tag: latest
  6. The push refers to repository [docker.io/library/diytomcat]
  7. f725786d3850: Preparing
  8. 111655768d68: Preparing
  9. e63e32bd0ac3: Preparing
  10. d0054e91bdb7: Preparing
  11. 174f56854903: Preparing
  12. denied: requested access to the resource is denied
  13. #报错--> 解决
  14. [root@localhost mytomcat]# docker images
  15. REPOSITORY TAG IMAGE ID CREATED SIZE
  16. diytomcat latest 8a8f9324c996 6 hours ago 759MB
  17. dockerfilemy 1.0 854426a238fb 7 hours ago 591MB
  18. dockerfileos02 latest 4fa78330abf4 14 hours ago 231MB
  19. dockerfilecentos01 latest 10e546aab68a 14 hours ago 231MB
  20. xiaohuyyds/centos latest 5c1eb233c81b 32 hours ago 231MB
  21. tomcat01 001 bb022423c461 2 days ago 684MB
  22. mysql 5.7 8aa4b5ffb001 8 days ago 462MB
  23. tomcat 9.0 6705ea17274a 10 days ago 680MB
  24. tomcat latest 0183eb12bb0c 10 days ago 680MB
  25. nginx latest fa5269854a5e 2 weeks ago 142MB
  26. elasticsearch 8.1.3 b543e34fe3ca 2 weeks ago 1.2GB
  27. hello-world latest feb5d9fea6a5 7 months ago 13.3kB
  28. centos 7 eeb6ee3f44bd 7 months ago 204MB
  29. centos latest 5d0da3dc9764 7 months ago 231MB
  30. portainer/portainer latest 580c0e4e98b0 13 months ago 79.1MB
  31. elasticsearch 7.6.2 f29a1ee41030 2 years ago 791MB
  32. #解决:增加一个tag
  33. [root@localhost mytomcat]# docker tag diytomcat xiaohuyyds/tomcat:1.0
  34. [root@localhost mytomcat]# docker images
  35. REPOSITORY TAG IMAGE ID CREATED SIZE
  36. diytomcat latest 8a8f9324c996 6 hours ago 759MB
  37. xiaohuyyds/tomcat 1.0 8a8f9324c996 6 hours ago 759MB
  38. dockerfilemy 1.0 854426a238fb 7 hours ago 591MB
  39. dockerfileos02 latest 4fa78330abf4 14 hours ago 231MB
  40. dockerfilecentos01 latest 10e546aab68a 14 hours ago 231MB
  41. xiaohuyyds/centos latest 5c1eb233c81b 32 hours ago 231MB
  42. tomcat01 001 bb022423c461 2 days ago 684MB
  43. mysql 5.7 8aa4b5ffb001 8 days ago 462MB
  44. tomcat 9.0 6705ea17274a 10 days ago 680MB
  45. tomcat latest 0183eb12bb0c 10 days ago 680MB
  46. nginx latest fa5269854a5e 2 weeks ago 142MB
  47. elasticsearch 8.1.3 b543e34fe3ca 2 weeks ago 1.2GB
  48. hello-world latest feb5d9fea6a5 7 months ago 13.3kB
  49. centos 7 eeb6ee3f44bd 7 months ago 204MB
  50. centos latest 5d0da3dc9764 7 months ago 231MB
  51. portainer/portainer latest 580c0e4e98b0 13 months ago 79.1MB
  52. elasticsearch 7.6.2 f29a1ee41030 2 years ago 791MB
  53. #docker push 上去即可 自己发布的镜像尽量带上自己的版本号
  54. [root@localhost mytomcat]# docker push xiaohuyyds/tomcat:1.0
  55. The push refers to repository [docker.io/xiaohuyyds/tomcat]
  56. f725786d3850: Pushing 537.6kB/221.1MB
  57. 111655768d68: Preparing
  58. e63e32bd0ac3: Pushing 528.5kB/318.1MB
  59. d0054e91bdb7: Pushing 3.072kB
  60. 174f56854903: Pushing 527.9kB/203.9MB
  61. ^C

阿里云镜像服务器上

略:因为自己没有买阿里云服务器