基于commit命令方式创建

docker的安装

[root@test01 ~]# yum install docker

[root@test01 ~]# systemctl enable docker

[root@test01 ~]# systemctl start docker

更新加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://z0ubh7pu.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

下载本地镜像

[root@test01 ~]# docker pull centos:7.4.1708

[root@test01 ~]# docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

docker.io/centos    7.4.1708            3afd47092a0e        3 months ago        196.6 MB

创建交互型容器

[root@test01 ~]# docker run -it --name="mysql_server" centos /bin/bash

安装mariadb服务

[root@e8126d0481d2 /]# yum -y install mariadb-server net-tools

初始化mariadb

[root@e8126d0481d2 /]# mysql_install_db --user=mysql

后台启动mariadb服务

[root@e8126d0481d2 /]# mysqld_safe &

[1] 114

[root@e8126d0481d2 /]#

180210 13:45:27 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.

180210 13:45:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@e8126d0481d2 /]# netstat -tunpl

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      -

创建mariadb登录密码,并可以指定ip登录

[root@e8126d0481d2 /]# mysqladmin -u root password '123456'

[root@e8126d0481d2 /]# mysql -u root -p

Enter password:

MariaDB [(none)]> show databases;

MariaDB [(none)]> use mysql;

MariaDB [mysql]> select Host from user where user='root';

MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

MariaDB [mysql]> update user set password=password('123456') where user='root' and host='e8126d0481d2';

MariaDB [mysql]> flush privileges;

MariaDB [mysql]> exit

容器登录验证

[root@e8126d0481d2 /]# mysql -u root -h 172.17.0.2 -p

Enter password:

MariaDB [(none)]> exit

创建容器启动脚本

[root@e8126d0481d2 ~]# cat run.sh

#!/bin/sh

mysqld_safe

创建镜像

[root@test01 ~]# docker ps -a

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES

e8126d0481d2        centos              "/bin/bash"         11 minutes ago      Exited (0) 8 seconds ago                       mysql_server

[root@test01 ~]# docker commit mysql_server mariadb:1.0

创建容器

[root@test01 ~]# docker run -d -p 13306:3306 mariadb:1.0 /root/run.sh

[root@test01 ~]# docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                     NAMES

eed3e88a1261        mariadb:1.0         "mysqld_safe"       4 seconds ago       Up 3 seconds        0.0.0.0:13306->3306/tcp   romantic_hamilton

主机登录验证

[root@test01 ~]# yum -y install mariadb

[root@test01 ~]# mysql -u root --port=13306 -p

MariaDB [(none)]>

docker容器创建MariaDB镜像的更多相关文章

  1. docker之创建MariaDB镜像的方法

    一.基于commit命令方式创建 docker的安装 ? 1 2 3 [root@test01 ~]# yum install docker [root@test01 ~]# systemctl en ...

  2. 【Docker】(9)---每天5分钟玩转 Docker 容器技术之镜像

    镜像是 Docker 容器的基石,容器是镜像的运行实例,有了镜像才能启动容器.为什么我们要讨论镜像的内部结构? 如果只是使用镜像,当然不需要了解,直接通过 docker 命令下载和运行就可以了. 但如 ...

  3. Docker 入门之docker容器创建

    使用docker容器的大多数人都是因为想要隔离不同运行环境的差异,使得自己的应用能更好的移植和部署.那么我们来看看掌握docker需要掌握哪些方面. 1,搭建docker环境 2,编译镜像并将其运行成 ...

  4. docker容器 如何精简镜像减小体积

    写在前面 我们在上篇<Docker容器 关于镜像构建的安全问题>一起学习了如何构建一个基于安全的镜像,这篇小作文我们会学习镜像构建的另一个关键性问题,为何别人打造的镜像只有10MB而我的有 ...

  5. 6.云原生之Docker容器Registry私有镜像仓库搭建实践

    转载自:https://www.bilibili.com/read/cv15219863/?from=readlist #1.下载registry仓库并设置数据存放的目录(并生成认证账号密码) doc ...

  6. Docker容器打包成镜像 - OpenDaylight官方 SDN Hub Tutorial VM 的docker镜像

    由于工作需要,在看OpenDaylight (一个SDN的开源控制器) 官方Tutorial有一个比较基础且介绍比较详细的文档(http://sdnhub.org/tutorials/opendayl ...

  7. docker centos7创建consul镜像以及用docker-compose启动镜像

    直接贴代码了: Dockfile: # Version 0.1 FROM kuba_centos7 MAINTAINER kuba si812cn@163.com # This is the rele ...

  8. Docker dockerfile创建Eclipse镜像初试

    抽空初步阅读了Docker技术入门与实战 [Kindle电子书] http://www.cnblogs.com/2018/p/4600116.html 现在想首先在开发环境下引入统一的环境,由于开发中 ...

  9. gitlab Docker容器创建命令以及从容器中备份gitlab仓库示例

    Gitlab容器启动命令: docker run -d --name gitlab --publish : --publish : --hostname gitlab-server --volume ...

随机推荐

  1. hdu 4998 Rotate 点的旋转 银牌题

    Rotate Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  2. Transformer模型总结

    Transformer改进了RNN最被人诟病的训练慢的缺点,利用self-attention机制实现快速并行. 它是由编码组件.解码组件和它们之间的连接组成. 编码组件部分由一堆编码器(6个 enco ...

  3. T2695 桶哥的问题——吃桶 题解

    校内测试 ------T3 对于这个题,首先想到的应该就是暴力枚举了吧,看看数据范围,60就是白送的啦!(但是我也不知道怎么才20分qwq) 思路分析: 这个题要你求所有套餐的总价值,先看一眼产生套餐 ...

  4. LG5283 异或粽子

    题意 共有\(n\)个数,选择\(k\)个不同的\([l,r]\)区间,使得它们的异或和最大 $ 1 \leq n \leq 5 \times 10^5,k \leq 2 \times 10^5$ 思 ...

  5. Nginx之核心结构体ngx_cycle_t

    1. ngx_listening_t 结构体 ngx_cycle_t 对象中有一个动态数组成员叫做 listening,它的每个数组元素都是 ngx_listening_t 结构体,而每个 ngx_l ...

  6. How to install WireShark on Linux

    https://linuxtechlab.com/install-wireshark-linux-centosubuntu/

  7. Flutter移动电商实战 --(2)建立项目和编写入口文件

    1.创建项目 采用AndroidStudio构建本项目,FIle>New>New Flutter Project… 创建后的项目如下图所示: 我们着重需要注意一下几个文件夹,其他的暂时不用 ...

  8. 性能测试 | 系统运行缓慢,CPU 100%,Full GC次数过多问题排查

    处理过线上问题的同学基本上都会遇到系统突然运行缓慢,CPU 100%,以及Full GC次数过多的问题.当然,这些问题的最终导致的直观现象就是系统运行缓慢,并且有大量的报警.本文主要针对系统运行缓慢这 ...

  9. linux下的开源NFC协议栈

    1. 协议栈名称 neardal 2. 源码 https://github.com/connectivity/neardal.git 3. 由谁维护? intel 4. 基于neardal的nfc协议 ...

  10. LC 583. Delete Operation for Two Strings

    Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 t ...