ubuntu 16.04 Dockerfile 安装mysql

本文介绍如何在Ubuntu系统中安装MariaDB。由于MariaDB的包并未包含在Ubuntu的标准仓库中,因此首先需要设置MariaDB的专用仓库。文中详细记录了配置过程、通过Docker构建MariaDB镜像的过程以及查看生成的镜像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

默认上MariaDB的包并没有在Ubuntu仓库中。要安装MariaDB,我们首先要设置MariaDB仓库。

配置MariaDB 仓库

# apt-get install software-properties-common

# apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db

# add-apt-repository 'deb http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main'

默认上MariaDB的包并没有在Ubuntu仓库中。要安装MariaDB,我们首先要设置MariaDB仓库。

# apt-get update
命中:1 http://cn.archive.ubuntu.com/ubuntu xenial InRelease
获取:2 http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty InRelease [3,234 B]
忽略:3 http://dl.google.com/linux/chrome/deb stable InRelease
获取:4 http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty/main amd64 Packages [5,626 B]
命中:5 http://dl.google.com/linux/chrome/deb stable Release
命中:6 https://apt.dockerproject.org/repo ubuntu-xenial InRelease
获取:8 http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty/main i386 Packages [5,627 B]
命中:9 http://ppa.launchpad.net/ansible/ansible/ubuntu xenial InRelease
命中:10 http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial InRelease
已下载 14.5 kB,耗时 6秒 (2,272 B/s)
正在读取软件包列表... 完成
W: http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu/dists/trusty/InRelease: 密钥 199369E5404BD5FC7D2FE43BCBCB082A1BB943DB 生成的数字签名使用了弱安全性摘要算法(SHA1)

Build Dockerfile

# docker build .
Sending build context to Docker daemon 7.68 kB
Step 1 : FROM ××××××
---> b3b17be3a5e6
Step 2 : MAINTAINER ××××××× <×××××@qq.com>
---> Using cache
---> 73d23501f6f0
Step 3 : ENV DATA_DIR /var/lib/mysql
---> Using cache
---> ad11a90574d3
Step 4 : RUN apt-get install -y mariadb-server && apt-get clean all
---> Running in c3d3c5af1bd0
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl
libmariadbclient18 libmysqlclient18 libreadline5 libterm-readkey-perl
mariadb-client-5.5 mariadb-client-core-5.5 mariadb-common mariadb-server-5.5
mariadb-server-core-5.5 mysql-common psmisc
Suggested packages:
libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test tinyca
The following NEW packages will be installed:
libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl
libmariadbclient18 libmysqlclient18 libreadline5 libterm-readkey-perl
mariadb-client-5.5 mariadb-client-core-5.5 mariadb-common mariadb-server
mariadb-server-5.5 mariadb-server-core-5.5 mysql-common psmisc
0 upgraded, 16 newly installed, 0 to remove and 88 not upgraded.
Need to get 11.7 MB of archives.
After this operation, 119 MB of additional disk space will be used.

Removing intermediate container cbe87abd3e25
Successfully built ca71e9f40ecf

查看生成的images

# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
×××        ×××× ca71e9f40ecf 42 seconds ago 620.3 MB

转载于:https://www.cnblogs.com/pyoyw/p/5874236.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值