mysql镜像管理

1、环境的安装

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
# 如果容器正在运⾏,容器是删除的,如果容器没有删除,对应的镜
像也⽆法删除
镜像的迁移
生成镜像
获得镜像ip地址
端口映射-p
数据持久化
线上考试系统的数据,虚拟化技术部署
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镜像
4、创建镜像容器
5、管理mysql
在容器外执行容器内部的命令
exec命令
# 容易内部已经安装的指令⽅可执⾏,否则⽆法执⾏
[root@docker001 ~]# docker exec c0 ifconfig
OCI runtime exec failed: exec failed: unable to
start container process: exec: "ifconfig":
executable file not found in $PATH: unknown
[root@docker001 ~]# docker exec c0 ls /
bin
dev
etc
home
lib
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
srvsys
tmp
usr
var
容器之间的依赖
容器的ip地址不稳定link
测试
测试:使用一个容器占用172.17.0.2,测试
每次启动都修改了/ets/hosts文件
1.docker容器的ip地址是不固定,如果要作为服务器使⽤,就必须能
够直接访问服务,不能直接使⽤ip,为容器设置域名,做端⼝映射也
能保证,确定是⼀旦停⽤之后端⼝被占⽤,就⽆法再次启动了2.docker run --link. 容器的名称或者是id:⾃定义域名
3.被link容器必须处于启动状态,否则当前容器⽆法启动
  • 15
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值