Docker操作 (十二)

简介: Docker操作 (十二)

发布自己的镜像
DockerHub
1、地址:https://hub.docker.com/注册自己的账号

image.png

2、确定这个账号可以登录

3、在这个服务器上提交自己的镜像

# centos7环境
root@localhost test]#  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 test]# docker login -u bruceliu1973
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

4、登录完毕,可以提交镜像,执行docker push命令

# 在centos7环境执行,但是出现一个问题
[root@localhost test]# docker push diytomcat
Using default tag: latest
The push refers to repository [docker.io/library/diytomcat]
41597dc9883c: Preparing
ba91795798ac: Preparing
43b27989aa87: Preparing
9445929b0a14: Preparing
74ddd0ec08fa: Preparing
denied: requested access to the resource is denied

# 解决push镜像的问题
# 给镜像增加一个tag
# 语法,[root@localhost test]#docker tag 容器id username/imagename   *****username 是dockerhub用户名,imagename是镜像名, imagename一定跟要push的镜像名一样,否则还是被拒绝
[root@localhost test]# docker tag 66f61ab160f4 bruceliu1973/diytomcat:1.0

# 修改为username/imagename:tag格式,push成功,如下图
[root@localhost tomcat]# docker push bruceliu1973/diytomcat:1.0
The push refers to repository [docker.io/bruceliu1973/diytomcat]
41597dc9883c: Pushed
ba91795798ac: Pushed
43b27989aa87: Pushed
9445929b0a14: Pushed
74ddd0ec08fa: Pushed
1.0: digest: sha256:f37ddc8c0333224c1e5a98588469919bad63aa5632722977c56720718e6886f5 size: 1372

image.png

注意:提交的时候也是按照镜像的层级来进行提交的。

阿里云镜像服务
1、登录阿里云

2、找到容器镜像服务(https://cr.console.aliyun.com/cn-hangzhou/instances)

3、创建命名空间

image.png

4、创建容器镜像
image.png

5、浏览阿里云

点击仓库,看到里面有一些基本信息。

image.png

# 登录阿里云
[root@localhost ~]# docker login --username=bruce刘晓伟 registry.cn-hangzhou.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.  # 宿主机这里存储用户名和密码,json文件未加密
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
# 登录成功以后,执行
[root@localhost ~]# docker tag[ImageId] registry.cn-hangzhou.aliyuncs.com/bruce_liu1973/bruce_liuxiaowei:[镜像版本号]
# 本例
[root@localhost ~]# docker tag[ImageId] registry.cn-  hangzhou.aliyuncs.com/bruce_liu1973/bruce_liuxiaowei:66f61ab160f4
# docker push,严格按照阿里云镜像推送命令格式执行,否则会被拒绝
[root@localhost ~]# docker push bruceliu1973/diytomcat:1.0  # 这个命令格式传DockerHub可以,传阿里云拒绝
# 按照阿里云格式推送到Registry,[镜像版本号]为上一步骤生成的版本号,此例为1.0,不是imageId
[root@localhost ~]# docker tag[ImageId] registry.cn-hangzhou.aliyuncs.com/bruce_liu1973/bruce_liuxiaowei:[镜像版本号] 
# 实际操作命令格式
[root@localhost ~]# docker push registry.cn-hangzhou.aliyuncs.com/bruce_liu1973/bruce_liuxiaowei:1.0

image.png
image.png

总结:阿里云容器镜像参考并严格按照官方文档格式执行命令。

以后如果想让自己的网站被大家访问,就可以把网站镜像发到阿里云或者DockerHub,然后大家pull—run— OK

小结:
image.png

镜像打包成一个tar压缩包,可以发送压缩包给别人,涉及到两个命令

[root@localhost ~]# docker save --help
Usage:  docker save [OPTIONS] IMAGE [IMAGE...]

Save one or more images to a tar archive (streamed to STDOUT by default)

Options:
  -o, --output string   Write to a file, instead of STDOUT
相关文章
|
1天前
|
安全 NoSQL Redis
Docker操作 (十四)
Docker操作 (十四)
|
1天前
|
NoSQL Java Redis
Docker操作 (十五)
Docker操作 (十五)
|
1天前
|
Java 应用服务中间件 Docker
Docker操作 (十一)
Docker操作 (十一)
|
1天前
|
Java Docker 微服务
Docker操作 (十六)
Docker操作 (十六)
|
2月前
|
Ubuntu NoSQL Linux
一文讲明Docker的基本使用,常见Docker命令使用 、Docker的安装使用等【详细说明+图解+概念+实践】
这篇文章详细介绍了Docker的基本使用,包括Docker的安装、常用命令、架构概念等,并通过图解和实践帮助读者快速掌握Docker的使用方法。
一文讲明Docker的基本使用,常见Docker命令使用 、Docker的安装使用等【详细说明+图解+概念+实践】
|
5月前
|
Docker 容器
Ubantu docker学习笔记(六)容器数据卷——补充实验
Ubantu docker学习笔记(六)容器数据卷——补充实验
|
运维 SpringCloudAlibaba 安全
docker基础篇:概念和命令
Docker是一种应用容器引擎。首先说一下何为容器,Linux系统提供了`Namespace`和`CGroup`技术实现环境隔离和资源控制,其中Namespace是Linux提供的一种内核级别环境隔离的方法,能使一个进程和该进程创建的子进程的运行空间都与Linux的超级父进程相隔离,注意Namespace只能实现运行空间的隔离,物理资源还是所有进程共用的,为了实现资源隔离,Linux系统提供了CGroup技术来控制一个进程组群可使用的资源(如CPU、内存、磁盘IO等),把这两种技术结合起来,就能构造一个用户空间独立且限定了资源的对象,这样的对象称为容器。
119 1
docker基础篇:概念和命令
|
Ubuntu NoSQL Shell
【Docker 基础教程】Docker命令运行原理及一些简单的操作命令
【Docker 基础教程】Docker命令运行原理及一些简单的操作命令
187 0
【Docker 基础教程】Docker命令运行原理及一些简单的操作命令
|
Docker 容器
Docker基础:docker查看日志用法笔记
大家在平常使用docker的时候,可能会遇到这样或者那样的问题,这个时候想排查问题的时候通常需要查看异常日志,这样才可以快速定位问题,从而解决实际的问题。今天就给大家聊聊Docker查看日志的用法,一起来看看吧!
Docker基础:docker查看日志用法笔记
|
应用服务中间件 Linux Docker
Docker基础:Docker运行原理笔记
Docker基于客户端(容器)-服务器(Docker引擎)结构的系统,Docker的守护进程运行在宿主主机上,客户端(容器)通过Socket向Docker引擎发送相应的指令,Docker服务器就会执行相应的命令。
Docker基础:Docker运行原理笔记