当前位置:  首页>> 技术小册>> Docker零基础到实战应用

DockerHub为docker的官方仓库.
其网址为:https://hub.docker.com.


在其官网上注册一个帐号后,可以使用命令登录退出:
登录:

  1. docker login

退出:

  1. docker logout

使用docker search命令,查找镜像:
如,查找centos镜像:

  1. $ docker search centos
  2. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  3. centos The official build of CentOS. 465 [OK]
  4. tianon/centos CentOS 5 and 6, created using rinse instea... 28
  5. blalor/centos Bare-bones base CentOS 6.5 image 6 [OK]
  6. saltstack/centos-6-minimal 6 [OK]
  7. tutum/centos-6.4 DEPRECATED. Use tutum/centos:6.4 instead. ... 5

在查找结果中,标有OFFICIAL列的为官方维护的镜像


使用docker pull 拉取镜像到本地:

  1. $ docker pull centos
  2. Pulling repository centos
  3. 0b443ba03958: Download complete
  4. 539c0211cd76: Download complete
  5. 511136ea3c5a: Download complete
  6. 7064731afe90: Download complete

使用docker push命令可以把本地的镜像推送到DockerHub:
将本地镜像打tag:

  1. $ docker tag ubuntu:18.04 username/ubuntu:18.04
  2. $ docker image ls
  3. REPOSITORY TAG IMAGE ID CREATED SIZE
  4. ubuntu 18.04 275d79972a86 6 days ago 94.6MB
  5. username/ubuntu 18.04 275d79972a86 6 days ago 94.6MB

将镜像push到远程仓库:

  1. $ docker push yourname/ubuntu:18.04
  2. $ docker search yourname
  3. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  4. username/ubuntu

该分类下的相关小册推荐: