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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[root@localhost ~]# docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: test 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 [root@localhost ~]# cat /root/.docker/config.json { "auths": { "https://index.docker.io/v1/": { "auth": "xpeW91QGRvY2tlckBxNTkuY29tYmx1ZWN1c2xpeW91Om" } } }
docker logout(登出仓库)
1 2 3 4 5 6
[root@blueculiyou ~]# docker logout --help
Usage: docker logout [SERVER]
Log out from a Docker registry. If no server is specified, the default is defined by the daemon.
1 2
[root@localhost ~]# docker logout Removing login credentials for https://index.docker.io/v1/
docker search(查找镜像)
1 2 3 4 5 6 7 8 9 10 11
[root@localhost ~]# docker search --help
Usage: docker search [OPTIONS] TERM
Search the Docker Hub for images
Options: -f, --filter filter Filter output based on conditions provided --format string Pretty-print search using a Go template --limit int Max number of search results (default 25) --no-trunc Don't truncate output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# 显示前5条匹配项镜像 [root@localhost ~]# docker search --limit 5 mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 11753 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 878 [OK] mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 89 schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 31 [OK] ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 3 [OK]
#搜索STARS > 800 以上的镜像 [root@localhost ~]# docker search --filter=STARS=800 mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 11753 [OK] mariadb MariaDB Server is a high performing open sou… 4482 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 878 [OK]
docker tag(给镜像打标签)
打标签主要是让镜像可以上传不同仓库用的
1 2 3 4 5
[root@localhost ~]# docker tag --help
Usage: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
1 2 3 4 5 6 7 8
#打完标签的新的镜像还是指向原来的镜像的 [root@localhost ~]# docker tag nginx mynginx [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mycentos latest 350c302fa1db About a minute ago 326MB nginx latest 605c77e624dd 2 weeks ago 141MB mynginx latest 605c77e624dd 2 weeks ago 141MB centos latest 5d0da3dc9764 4 months ago 231MB
docker pull(拉取镜像)
1 2 3 4 5 6 7 8 9 10 11
[root@localhost ~]# docker pull --help
Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST]
Pull an image or a repository from a registry
Options: -a, --all-tags Download all tagged images in the repository --disable-content-trust Skip image verification (default true) --platform string Set platform if server is multi-platform capable -q, --quiet Suppress verbose output
#下载镜像 带版本号 [root@localhost ~]# docker pull redis:6 6: Pulling from library/redis Digest: sha256:619af14d3a95c30759a1978da1b2ce375504f1af70ff9eea2a8e35febc45d747 Status: Downloaded newer image for redis:6 docker.io/library/redis:6
docker push(上传镜像到仓库)
1 2 3 4 5 6 7 8 9 10
[root@localhost ~]# docker push --help
Usage: docker push [OPTIONS] NAME[:TAG]
Push an image or a repository to a registry
Options: -a, --all-tags Push all tagged images in the repository --disable-content-trust Skip image signing (default true) -q, --quiet Suppress verbose output
1 2 3 4 5 6 7 8 9 10 11
[root@localhost ~]# docker tag nginx localhost/mynginx:0.1
[root@localhost ~]# docker push localhost/mynginx:0.1 The push refers to repository [docker.io/localhost/mynginx] d874fd2bc83b: Mounted from library/nginx 32ce5f6a5106: Mounted from library/nginx f1db227348d0: Mounted from library/nginx b8d6e692a25e: Mounted from library/nginx e379e8aedd4d: Mounted from library/nginx 2edcec3590a4: Mounted from localhost/myredis 0.1: digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3 size: 1570