Happy3w

Docker-运行应用

2017.01.07
Hello Docker中提到了一些安装应用的问题,现在我们有一个实际的问题:本地运行Mysql。 一般过程应该是 1.下载Mysql安装包 2.安装 3.配置,启动 4.不用的时候卸载 我们在Docker世界的解决方式是 1.找到合适版本的Mysql 2.启动 3.删除不需要的Container或者Image 开工 1.找合适的版本 执行命令docker search mysql,显示 NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relati... 3648 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Crea... 239 [OK] centurylink/mysql Image containing mysql. Optimized to be li... 47 [OK] sameersbn/mysql 41 [OK] zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 20 [OK] appcontainers/mysql Centos/Debian Based Customizable MySQL Con... 8 [OK] marvambass/mysql MySQL Server based on Ubuntu 14.04 7 [OK] dnhsoft/mysql-utf8 Inherits the official MySQL image configur... 5 [OK] bitnami/mysql Bitnami MySQL Docker Image 3 [OK] frodenas/mysql A Docker Image for MySQL 3 [OK] alterway/mysql Docker Mysql 3 [OK] yfix/mysql Yfix docker built mysql 2 [OK] drupaldocker/mysql MySQL for Drupal 2 [OK] debezium/example-mysql Example MySQL database server with a simpl... 1 [OK] lysender/mysql MySQL base image using Ubuntu 16.04 Xenial 1 [OK] coscale/mysql CoScale custom configuration of the offici... 1 [OK] newrelic/mysql-plugin New Relic Plugin for monitoring MySQL data... 1 [OK] captomd/mysql CaptoMD mysql configuration 0 [OK] nanobox/mysql MySQL service for nanobox.io 0 [OK] datajoint/mysql MySQL image pre-configured to work smoothl... 0 [OK] projectomakase/mysql Docker image for MySQL 0 [OK] cloudposse/mysql Improved `mysql` service with support for ... 0 [OK] tozd/mysql MySQL (MariaDB fork) Docker image. 0 [OK] 1maa/mysql MySQL database 0 [OK] dockerizedrupal/mysql mysql-for-docker 0 [OK] 找到很多,建议使用STARS数量最多的 mysql MySQL is a widely used, open-source relati... 3648 [OK] 这个image的名称就是mysql,没有任何的前缀 其他更为详细的信息,包括版本不好和使用方法可以在https://hub.docker.com找到,打开后直接搜索即可。懒癌患者可以直接下一步。 2.启动 执行命令docker run --name my-mysql-server -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql 控制台显示如下 Unable to find image 'mysql:latest' locally latest: Pulling from library/mysql 75a822cd7888: Already exists b8d5846e536a: Pull complete b75e9152a170: Pull complete 832e6b030496: Pull complete fe4a6c835905: Pull complete c3f247e29ab1: Pull complete 21be3e562071: Pull complete c7399d6bf033: Pull complete ccdaeae6c735: Pull complete 713c7d65b0d3: Pull complete 86c18539deb2: Pull complete Digest: sha256:9ef4478a3aa597f59b2266d5702f55f29acc468b5bf3518c3c90cbca4e243823 Status: Downloaded newer image for mysql:latest 84f92f38fe5f092f42ff65b5bc31322edae5663ff5582045078b351504ebca6d 需要等待一会,毕竟需要下载mysql。 现在运行docker ps可以看到刚刚启动的mysql,已经工作了 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e5ba75509bf3 mysql "docker-entrypoint..." 15 minutes ago Up 2 seconds 0.0.0.0:3306->3306/tcp my-mysql-server 使用其他工具连接一下mysql,可以发现已经可以是用了 >mysql -h 127.0.0.1 -u root -p Enter password:(密码是我们启动程序时设置的123456) Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 MySQL Community Server (GPL) Copyright (c) 2000, 2015, 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> 3.删除 想要停止这个mysql只需要执行docker stop my-mysql-server 想要删除这个mysql,执行docker rm -f my-mysql-server 想要彻底删除mysql程序文件,执行docker rmi -f mysql 保证系统里面不会残留任何东西,不会动其他应用的任何配置,安装过程只有一句话 上一篇    下一篇