最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

docker 启动简单的开发环境(mysql, redis, etcd)

运维笔记admin36浏览0评论

docker 启动简单的开发环境(mysql, redis, etcd)

docker 启动简单的开发环境(mysql, redis, etcd)

docker开启容器分为两种,一种是命令启动,一种是用yaml启动

本片文章用到的是yaml启动

以下是启动脚本:env.yaml

version: "3"
services:jump_etcd:container_name: jump_etcdimage: bitnami/etcd:3privileged: truevolumes:- "$CHDIR/etcd_data:/opt/bitnami/etcd/data"environment:- "ETCD_ADVERTISE_CLIENT_URLS=:2379"- "ETCD_LISTEN_CLIENT_URLS=:2379"- "ETCD_LISTEN_PEER_URLS=:2380"- "ETCD_INITIAL_ADVERTISE_PEER_URLS=:2380"- "ALLOW_NONE_AUTHENTICATION=yes"- "ETCD_INITIAL_CLUSTER=node1=:2380"- "ETCD_NAME=node1"- "ETCD_DATA_DIR=/opt/bitnami/etcd/data"ports:- "2379:2379"- "2380:2380"jump_redis:container_name: jump_redisimage: harbor.corp.sdo/library/redis:6.0volumes:- "$CHDIR/redis_data:/data"ports:- "16379:6379"command:"redis-server --appendonly yes"jump_mysql:container_name: jump_mysqlimage: harbor.corp.sdo/library/mysql:8.0environment:- "MYSQL_ROOT_PASSWORD=123456"- "MYSQL_DATABASE=jump"volumes:- "./myf:/etc/mysql/myf"ports:- "13306:3306"

container_name:是容器的名字

image:是启动容器的镜像,如果本地没有该镜像,则会到远程镜像库里去下载,安装不同版本的都只需要改这个参数就可以了

在启动mysql时用到了配置myf,这个可以在网上直接down一个,放在yaml相同的目录

我这里提供了一个myf,大家可以copy使用

以下是myf文档

# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA#
# The MySQL  Server configuration file.
#
# For explanations see
# .html[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL
skip_ssl
default_authentication_plugin = mysql_native_password
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0# Custom config should go here
!includedir /etc/mysql/conf.d/

docker的启动yaml启动好后,需要用命令执行yaml

启动:docker-compose -f env.yaml up -d

关闭:docker-compose -f env.yaml down

发布评论

评论列表(0)

  1. 暂无评论