docker筆記18-案例-安裝mysql
1、docker hub上面查詢mysql映象
[root@t-docker tomcatlogs]# docker search mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 6845 [OK] mariadb MariaDB is a community-developed fork of MyS… 2185 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 502 [OK] percona Percona Server is a fork of the MySQL relati… 365 [OK] zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 120
2、從docker hub上(或阿里雲加速器)拉取mysql映象到本地
[root@t-docker tomcatlogs]# docker pull mysql:5.6 5.6: Pulling from library/mysql be8881be8156: Already exists c3995dabd1d7: Pulling fs layer 9931fdda3586: Pulling fs layer bb1b6b6eff6a: Pulling fs layer a65f125fa718: Pulling fs layer 62fa8db7a5dc: Pulling fs layer a65f125fa718: Waiting 0f5681d76128: Pull complete 56d3348c5742: Pull complete b93f67de42c4: Pull complete 5adba6c10127: Pull complete Digest: sha256:2e48836690b8416e4890c369aa174fc1f73c125363d94d99cfd08115f4513ec9 Status: Downloaded newer image for mysql:5.6
[root@t-docker tomcatlogs]# docker images mysql REPOSITORY TAG IMAGE ID CREATED SIZE mysql 5.6 7edb93321b06 4 weeks ago 256MB
3、使用mysql映象建立容器(也叫執行映象)
[root@t-docker chenzx]# docker run -p 12345:3306 --name mysql -v /volume/mysql/conf:/etc/mysql/conf.d -v /volume/mysql/logs:/logs -v /volume/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
命令說明:
-p 12345:3306:將主機的12345埠對映到docker容器的3306埠;
--name mysql:執行容器的名字
-v 掛載宿主機上的資料捲到容器裡面
-e MYSQL_ROOT_PASSWORD=123456:初始化root的密碼
-d mysql:5.6:後臺執行mysql5.6
[root@t-docker chenzx]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6dc80df5e339 mysql:5.6 "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:12345->3306/tcp mysql
[root@t-docker chenzx]# docker exec -it 6dc80df5e339 /bin/bash root@6dc80df5e339:/# mysql -uroot -p123456 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 1 Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. 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. mysql> status ; -------------- mysql Ver 14.14 Distrib 5.6.41, for Linux (x86_64) using EditLine wrapper Connection id:1 Current database: Current user:root@localhost SSL:Not in use Current pager:stdout Using outfile:'' Using delimiter:; Server version:5.6.41 MySQL Community Server (GPL) Protocol version:10 Connection:Localhost via UNIX socket Server characterset:latin1 Db characterset:latin1 Client characterset:latin1 Conn. characterset:latin1 UNIX socket:/var/run/mysqld/mysqld.sock Uptime:5 min 10 sec Threads: 1 Questions: 5 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.016 --------------
4、備份docker容器裡面的MySQL
[root@t-docker chenzx]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6dc80df5e339 mysql:5.6 "docker-entrypoint.s…" 16 minutes ago Up 16 minutes 0.0.0.0:12345->3306/tcp mysql
[root@t-docker chenzx]# docker exec 6dc80df5e339 sh -c 'exec mysqldump -uroot -p123456 -B mysql' > mysql.sql
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28916011/viewspace-2213405/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Ubuntu安裝docker筆記UbuntuDocker筆記
- Docker筆記(三):Docker安裝與配置Docker筆記
- docker筆記3-docker的安裝Docker筆記
- Docker安裝(學習筆記一)Docker筆記
- docker 安裝 mysqlDockerMySql
- docker安裝mysqlDockerMySql
- Docker 安裝mysqlDockerMySql
- [mysql/docker] 基於Docker安裝MYSQLMySqlDocker
- Docker 入門學習筆記一:Ubuntu安裝 DockerDocker筆記Ubuntu
- Mysql學習筆記(安裝篇)MySql筆記
- CentOS學習筆記 – 6. docker安裝CentOS筆記Docker
- docker安裝mysql映象DockerMySql
- Docker 安裝 Mysql 5.7DockerMySql
- docker容器安裝MySQLDockerMySql
- docker筆記16-Dockerfile案例-ONBUILD命令案例Docker筆記UI
- Mysql學習筆記1--安裝MySql筆記
- docker筆記15-Dockerfile案例-CMD、ENTRYPOINT案例Docker筆記
- Docker 學習筆記-基本概念與安裝Docker筆記
- Docker安裝記錄Docker
- docker 安裝 MySQL (參考)DockerMySql
- Docker 安裝 MySQL8.0DockerMySql
- 【微服務】docker安裝mysql微服務DockerMySql
- Docker安裝Mysql服務DockerMySql
- docker安裝mysql8DockerMySql
- 伺服器安裝docker 以及使用docker安裝mysql及svn伺服器DockerMySql
- CentOS7安裝Docker遇到的問題筆記CentOSDocker筆記
- puppet之mysql批量安裝案例MySql
- mysql安裝記MySql
- Linux 下 docker 安裝 MySQLLinuxDockerMySql
- 使用docker安裝mysql和redisDockerMySqlRedis
- docker 安裝mysql redis activemq rabbitmqDockerMySqlRedisMQ
- Docker教程之七安裝 MySQLDockerMySql
- Docker Centos安裝Mysql5.6DockerCentOSMySql
- docker筆記14-Dockerfile案例-自定義mycentosDocker筆記CentOS
- docker和docker compose安裝使用、入門進階案例Docker
- Docker筆記四之執行MySQLDocker筆記MySql
- [第十九篇]——Docker 安裝 MySQLDockerMySql
- 18-《ARKit by Tutorials》讀書筆記5:特殊物理效果筆記