前言: 我这里为了方便大家使用写了两个版本分别是官方docker提交方法和阿里云的方便大家熟悉各个环境 国内的阿里云提供了国内的docker仓库,而且docker有单独的密码进行登录,如果不指定tag拉取镜像默认版本是“lastest ”大家可以快速使用方法如下:
docker官方提交方法 官方仓库使用也需要注册帐号 1.在docker官网上注册账户后创建一个nginxs/centos7的仓库https://hub.docker.com/
2.在你本地登录1
2
3
4
5
6
7
8
9
| [iyunv@salt-node1
.docker]# 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: nginxs
Password:
Login Succeeded
|
3.给指定镜像ID打tag1
2
3
| 语法: docker tag [image_ID] path/image:[tag]
[iyunv@salt-node1 ~]#
docker tag 00f6c5817350 nginxs/centos7:last
|
4.提交你的镜像语法:docker pushpath/image:[tag] 1
2
3
4
5
6
7
8
| [iyunv@salt-node1
.docker]# docker push nginxs/centos7:last
The push refers to a
repository [docker.io/nginxs/centos7]
34e7b85d83e4: Pushed
last: digest:
sha256:dafc45b8b533d5ad5564a3821e9e1a252b58f44e69c6052bddcd00139782ee08 size:
529
|
5.提交完成你就可以就看到你的镜像多了一个tag
6.运行一个容器,-t 并在本地创建一个伪终端,-I 并建立一个标准输入的连接允许操作
1
2
3
4
5
6
7
8
9
10
11
| [iyunv@salt-node1
.docker]# docker run -t -i
nginxs/centos7:last /bin/bash
[iyunv@5993a66d45c5
/]# ps -ef
UID PID
PPID C STIME TTY TIME CMD
root 1
0 5 16:05 ? 00:00:00 /bin/bash
root 13
1 0 16:05 ? 00:00:00 ps -ef
|
###########################| 华丽的分割线 |################################
这里开始说一下阿里云docker的用法,阿里云docker的密码是单独的在这里
登录registry的用户名是您的阿里云账号全名,密码是您开通namespace时设置的密码。 1
2
3
4
5
6
7
8
9
| [iyunv@salt-node1
~]# docker login
--username=nginxs@126.com registry.cn-hangzhou.aliyuncs.com
Password:
Email:
nginxs@126.com
WARNING: login
credentials saved in /root/.docker/config.json
Login Succeeded
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| [iyunv@salt-node1 ~]#
docker pull registry.cn-hangzhou.aliyuncs.com/cloudist/redis
Using default tag:
latest
Trying to pull
repository registry.cn-hangzhou.aliyuncs.com/cloudist/redis ...
latest: Pulling from
registry.cn-hangzhou.aliyuncs.com/cloudist/redis
81cc5f26a6a0: Pull
complete
a3ed95caeb02: Pull
complete
d43cb752619e: Pull
complete
861e96e7ae14: Pull
complete
7fae3dcea8af: Pull
complete
b46c28ddbe0c: Pull
complete
2d50fb4bcfa7: Pull
complete
c8fc9e7dfb8b: Pull
complete
a1a961e320bc: Pull
complete
Digest:
sha256:598a6f07bdb0763ee3fc32cdcb2c6e99e16d6cf204f1ac4f97288c61e3e5a1af
Status: Downloaded
newer image for registry.cn-hangzhou.aliyuncs.com/cloudist/redis:latest
|
下面的“f062fe1dd4fe”是我的镜像ID,last是我的镜像版本 1
2
3
| [iyunv@salt-node1 ~]#
docker tag f062fe1dd4fe
registry.cn-hangzhou.aliyuncs.com/forker/centos7ssh:last
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [iyunv@salt-node1 ~]#
docker push registry.cn-hangzhou.aliyuncs.com/forker/centos7ssh:last
The push refers to a
repository [registry.cn-hangzhou.aliyuncs.com/forker/centos7ssh]
acce4ec5f074: Pushed
5d450a8c7e38: Pushed
e8fd5087fa08: Pushed
cf394a2f01e4: Pushed
f16d5ac23cee: Pushed
57861a68f43a: Pushed
97ca462ad9ee: Pushed
last: digest:
sha256:b0851324bac55083172ed2068dfb388acabdce14dffdb9787f4e6c044b524f19 size:
1764
|
1
2
3
4
| [iyunv@salt-node1
bai]# docker run centos7 cat /etc/redhat-release
CentOS Linux release
7.3.1611 (Core)
|
|