mysql镜像管理

docker容器==》k8s编排=〉openstack
存储 监控 ⽇志 以及其他的内容
回顾
1.环境的安装
cat << EOF | tee /etc/modules-load.d/k8s.conf
> overlay
> br_netfilter
> EOF
overllay
br_netfilter
cat << EOF | tee /etc/sysctl.d/k8s.conf
> net.bridge.bridge-nf-call-iptables = 1
> net.bridge.bridge-nf-call-ip6tables = 1
> net.ipv4.ip_forward = 1
> EOF
# yum 镜像
# yum 服务器和客户端2.镜像案例
# 启动服务
systemctl start docker.service
# 查看镜像
docker images
docker image ls
# 删除镜像
docker rmi centos:latest
docker rmi 5axxxx(img id)
# 在公共仓库查找镜像
docker search centos
# 拉取镜像
docker pull centos
2.管理容器 容器就是在镜像上添加了⼀个可写层
# 创建容器docker run -it --name c0 centos:latest /bin/bash
# 查看容器
docker ps # 查看up的容器
docker ps --all #查看所有的容器
# 切回宿主 ctrl p q
#启动容器
docker start c0 c1
#停⽤容器
docker stop c0 c1
#删除容器
docker rm c0 c1
# 如果容器正在运⾏,容器是删除的,如果容器没有删除,对应的镜
像也⽆法删除
镜像的迁移
# save
docker save -o centos.tar centos:latest
# load
docker save -i centos.tar⽣成镜像
# export 通过容器⽣成tar
docker export centoshttpd.tar c0
# import 通过tar引⼊镜像
docker import -m "dafdsfa" centoshtpd centos:httpd
docker images
获得镜像ip地址
# 进⼊到镜像的bash
yum install iprouter,net-tools
ip a
# 使⽤exec指令
docker exec 容器名称或者id yum -y install iproute
docker exec c0 ip a
# 直接使⽤inspect命令
dcoker inspoct c0 端⼝映射 -p
docker run -it --name c0 -p80:80/tcp centos:latest
/bin/bash
docker run -it --name c1 -p80 centos:latest
/bin/bash # 宿主会指定⼀个⼤于等于3278的端⼝给容器
docker ps --all # 查看实际给予的端⼝
docker run -it --name c2 -p10.1.1.51::80
centos:latest /bin/bash
数据持久化
docker run -it --name c4 -v /opt/:/var/www/html/
centos:latest /bin/bash
线上考试系统的数据 虚拟化技术部署
1.部署前段服务器
# 1.将资源上传到服务器
scp -r dist/ root@192.168.71.50:~# 2创建基础容器 在服务器上
systemctl start docker.service
docker pull centos
docker run -it --name c0 centos:latest /bin/bash
# 3 在容器中修改yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo
https://mirrors.aliyun.com/repo/Centos-vault-
8.5.2111.repo
yum clean all && yum makecache
# 4.在容器中安装epel
yum -y install epel-release
# 5.在容器中安装nginx
yum -y install nginx
# 6.ctrl pq
# 7.导出tar包
docker export -o centos_nginx.tar
# 8.引⼊tar包,称为镜像
docker import -m "维护世界和平" centos_nginx.tar
centos:nginx
# 9.查看镜像
docker image ls
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
centos nginx 9afbddb29074 10 seconds
ago 366MBmysql latest a82a8f162e18 4 weeks ago
586MB
centos latest 5d0da3dc9764 2 years ago
231MB
# 10.停⽤c0容器,删除c0容器
# 11.创建新的centos nginx容器,在创建的同时指定端⼝,以及
挂载⽬录
docker run -it --name c0 -p80:80/tcp -v
/opt/:/usr/share/nginx/html centos:nginx /bin/bash
# 12在容器内部启动nginx服务
nginx
#ctrl p q
# 13 在宿主上把dist⽬录中的⽂件复制opt⽬录中
cp -r dist/* /opt
1.启动docker守护进程
[root@docker001 ~]# systemctl start docker.service2.搜索mysql镜像
[root@docker001 ~]# docker search mysql
NAME DESCRIPTION
STARS OFFICIAL
mysql MySQL is a widely used, open
source relation… 15322 [OK]
bitnami/mysql Bitnami container image for
MySQL 114
google/mysql MySQL server for Google
Compute Engine 25
elestio/mysql Mysql, verified and packaged
by Elestio 0
rapidfort/mysql RapidFort optimized, hardened
image for MySQL 25
circleci/mysql MySQL is a widely used, open
source relation… 30
ubuntu/mysql MySQL open source fast,
stable, multi-thread… 64
javanile/mysql MySQL for development
0
eclipse/mysql Mysql 5.7, curl, rsync
1
ilios/mysql Mysql configured for running
Ilios 1
cimg/mysql
3bitnamicharts/mysql
0
mirantis/mysql
0
docksal/mysql MySQL service images for
Docksal - https://d… 0
linuxserver/mysql A Mysql container, brought to
you by LinuxSe… 41
datajoint/mysql MySQL image pre-configured to
work smoothly … 2
ddev/mysql ARM64 base images for ddev
dbserver-mysql-8.… 1
phpmyadmin phpMyAdmin - A web interface
for MySQL and M… 1017 [OK]
vulhub/mysql
0
drud/mysql
1
nasqueron/mysql
1
corpusops/mysql
https://github.com/corpusops/docker-images/ 0
jumpserver/mysql
1
openeuler/mysql
0encoflife/mysql
0
3.拉取mysql镜像
[root@docker001 ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
6e839ac3722d: Pull complete
ad912193ad5f: Pull complete
25d13d87fd8d: Pull complete
004d383c75ef: Pull complete
6d9bbc82a0b8: Pull complete
81fec07ea550: Pull complete
83357cb2d3a5: Pull complete
8ffe968b82c1: Pull complete
30dfd9a7ed57: Pull complete
35844ae33cbe: Pull complete
Digest:
sha256:86cdfe832c81e39a89cfb63c3fde1683c41cc00ef91e
67653c9c1df0ba80f454
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
[root@docker001 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED
SIZEcentos nginx 12fea1b890de 13 hours
ago 366MB
centos java17 b6bf774de7bb 14 hours
ago 550MB
centos_httpd v0 fffc96d791d5 39 hours
ago 309MB
centos_yum v0 191d9c84f461 39 hours
ago 260MB
mysql latest a82a8f162e18 4 weeks ago
586MB
centos latest 5d0da3dc9764 2 years ago
231MB
4.创建镜像容器
[root@docker001 ~]# docker run -d --name my01 -e
MYSQL_ROOT_PASSWORD=root -p 3306:3306 mysql:latest
9338d672d3d819e5eb35fcf9fb5cd8fe88daf5a84b00ab0a4b3
3fc9b9ba87d8a
# -d 后台运⾏,并输出hashcode
# -e MYSQL_ROOT_PASSWORD=root 设置mysql密码
# -p 映射3306端⼝
5.管理mysql[root@docker001 ~]# docker exec -it my01 mysql -
uroot -proot
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 9
Server version: 9.0.1 MySQL Community Server - GPL
Copyright (c) 2000, 2024, 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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值