当前位置: 首页 > news >正文

docker升级docker pull mysql:5.7.37异常

一、使用背景

我们在使用docker拉取mysql命令时,数据库服务器,网络未开通外网,拉取镜像失败

但是我们还是想用docker部署则可以通过以下方式获取

前提:环境网络通可以pull mysql镜像

[root@VM-20-10-centos opt]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED       STATUS             PORTS                                                  NAMES
ae0a0e631153   mysql:5.7.37   "docker-entrypoint.s…"   9 hours ago   Up About an hour   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   mysql
[root@VM-20-10-centos opt]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
mysql        latest    7ce93a845a8a   4 weeks ago   586MB
mysql        5.7.37    82d2d47667cf   2 years ago   450MB
[root@VM-20-10-centos opt]# docker save -o 1.tar   mysql:5.7.37

说明:其中  docker save -o 1.tar   mysql:5.7.37 来自IMAGE

1、先保存镜像为tar文件

 docker save -o 1.tar   mysql:5.7.37

2、从tar文件加载镜像、上传至目标服务器

docker load -i 1.tar
[root@VM-20-10-centos backup]# docker load -i 1.tar
0ad3ddf4a4ce: Loading layer [==================================================>]  72.54MB/72.54MB
894a6e83a96f: Loading layer [==================================================>]  338.4kB/338.4kB
e9303ab783fe: Loading layer [==================================================>]  9.557MB/9.557MB
96759eecc124: Loading layer [==================================================>]  4.087MB/4.087MB
b4dac6cae747: Loading layer [==================================================>]  2.048kB/2.048kB
765a4b7dea37: Loading layer [==================================================>]  55.16MB/55.16MB
1b09b37f4930: Loading layer [==================================================>]  6.656kB/6.656kB
ae74b19e2947: Loading layer [==================================================>]  3.584kB/3.584kB
9172c7574e83: Loading layer [==================================================>]  313.2MB/313.2MB
79e0c651efb2: Loading layer [==================================================>]   16.9kB/16.9kB
a1f00f3b2b70: Loading layer [==================================================>]  1.536kB/1.536kB
Loaded image: mysql:5.7.37

 3、初始化mysql

sudo docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7.37

说明:其中root至的是密码、mysql: 5.7.37拉去取镜像版本

 4、执行结果 

[root@VM-20-10-centos backup]# sudo docker run -p 3306:3306 --name mysql \
> -v /mydata/mysql/log:/var/log/mysql \
> -v /mydata/mysql/data:/var/lib/mysql \
> -v /mydata/mysql/conf:/etc/mysql \
> -e MYSQL_ROOT_PASSWORD=root \
> -d mysql:5.7.37
74f1da1fcf877a835e47afd248a05ad08a3ce39b94b8156365e0dcf790edf716
[root@VM-20-10-centos backup]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                                  NAMES
74f1da1fcf87   mysql:5.7.37   "docker-entrypoint.s…"   10 seconds ago   Up 10 seconds   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   mysql

二、FAQ拉取镜像密码

-e MYSQL_ROOT_PASSWORD=root \ 未生效  使用root登陆未生效,从其他服务器拉取的mysql镜像密码是123456使用123456登陆msyql成功进入

mysql> exit
Bye
root@74f1da1fcf87:/# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@74f1da1fcf87:/# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.37 MySQL Community Server (GPL)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

好了,至于为什么不重要 重新修改个密码吧

还有的小伙伴甚至docker都下载失败看过来

这位博主已经踩好坑进来坐

linux安装docker_linux 安装docker-CSDN博客


http://www.mrgr.cn/news/9208.html

相关文章:

  • 【鼠鼠学AI代码合集#3】简单的数据操作 (pytorch)
  • BCEWithLogitsLoss
  • 大模型在应用开发安全左移实践
  • C#中的压缩与解压缩:掌握内置功能的艺术
  • Matlab自学笔记三十四:表table的排序、查找、提取、删除、计算、与结构数组的转换
  • CSS\JS实现页面背景气泡logo上浮效果
  • ubuntu20.04源码编译安装qemu(qemu8.2)
  • 01 BlockChain--
  • ReactRouter6快速入门教程
  • webdriver 反爬虫 (selenium反爬虫) 绕过
  • 手机谷歌浏览器怎么用
  • 【HuggingFace Transformers】BertSdpaSelfAttention源码解析
  • C语言占领游戏
  • 无人机PX4飞控 | 电源系统详解与相关代码
  • C语言文件迷宫
  • ThreeJs学习-层级模型
  • 前端面试宝典【设计模式】【5】
  • 短剧系统搭建:从零搭建高效创意内容平台教程,源码分享+正版片源授权指南
  • RING总线(环形总线)Intel大小核的由来
  • 『功能项目』禁止射线穿透行为【05】