docker制作mysql-client的镜像(基于centos)

linux 专栏收录该内容
66 篇文章 1 订阅

由于我的程序需要往mysql数据库中存数据,用到了libmysqlclient.so,所以把我的程序放到docker中运行的时候,需要在docker镜像中包含libmysqlclient.so。

网上有基于alpine的mysql-client。感觉不行。我们还是用centos的镜像感觉保险一点。

1.build.sh

从mysql的官网下载mysql相关rpm到本地

#!/bin/bash


wget https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.27-1.el7.x86_64.rpm
wget https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.27-1.el7.x86_64.rpm
wget https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.27-1.el7.x86_64.rpm



docker build -t mysql-client  .

 

Dockerfile



FROM centos:7

MAINTAINER along <aaaa@gmail.com>

#ADD /mysql-community-common-5.7.27-1.el7.x86_64.rpm  /mysql-community-common-5.7.27-1.el7.x86_64.rpm
#ADD /mysql-community-libs-5.7.27-1.el7.x86_64.rpm 	 /mysql-community-libs-5.7.27-1.el7.x86_64.rpm
#ADD /mysql-community-client-5.7.27-1.el7.x86_64.rpm  /mysql-community-client-5.7.27-1.el7.x86_64.rpm

ARG MYSQL_1=/mysql-community-common-5.7.27-1.el7.x86_64.rpm
ARG MYSQL_2=/mysql-community-libs-5.7.27-1.el7.x86_64.rpm
ARG MYSQL_3=/mysql-community-client-5.7.27-1.el7.x86_64.rpm

ADD $MYSQL_1 $MYSQL_1
ADD $MYSQL_2 $MYSQL_2
ADD $MYSQL_3 $MYSQL_3
# -----------------------------------------------------------------------------
# MySQL client
# -----------------------------------------------------------------------------
RUN	   yum install -y $MYSQL_1 \
	&& yum install -y $MYSQL_2 \
	&& yum install -y $MYSQL_3 \
	&& rm -rf $MYSQL_1 \
	&& rm -rf $MYSQL_2 \
	&& rm -rf $MYSQL_3 \
	&& rm -rf /var/cache/yum/* \

 

 

reference:

https://github.com/arey/mysql-client/blob/master/Dockerfile

https://stackoverflow.com/questions/30082674/how-to-install-a-local-rpm-file-when-building-docker-instance/30083919

 

 

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值