Docker安装各服务命令

  • 2017-09-05
  • 284
  • 3
  • 0

docker 加速

安装/升级你的Docker客户端

您可以通过阿里云的镜像仓库下载:mirrors.aliyun.com/help/docker-engine

或执行以下命令:

curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -

如何使用Docker加速器
针对Docker客户端版本大于1.10的用户

您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器:

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

参考:https://cr.console.aliyun.com/?spm=5176.1971733.2.28.394b9fbdrASJma#/accelerator

docker启动所有容器命令

docker start $(docker ps -a -q)

tomcat

server.xml , 后加

Context path="" docBase="/home/tomcat/apache-tomcat-8.5.16/webapps/doudou/" debug="0"/>
docker run -p 1006:8080 -it -v /home/tomcat/:/home/tomcat/ --name tomcat  docker.io/openjdk /bin/bash

redis

docker run -p 6379:6379 -itd --name redis redis

mysql

docker run --name mysql -p 3306:3306 -e MYSQL\_ROOT\_PASSWORD=new.1234 -d mysql

rabbitmq

docker run -p 15672:15672 -itd --name rabbitmq letsxo/rabbitmq

nginx

docker run -it -p 80:80 -v `pwd`/www:/www -v `pwd`/config:/etc/nginx/sites-enabled  -v `pwd`/logs:/var/log/nginx nginx

elasticSearch 2.3.5

docker run -d -p 9200:9200 --name="es" elasticsearch:2.3.5
  • 安装ansj插件
${ES_HOME}
./bin/plugin install http://maven.nlpcn.org/org/ansj/ \
elasticsearch-analysis-ansj/2.3.5.3/elasticsearch-analysis- \
ansj-2.3.5.3-release.zip
  • 安装head插件
    ${ES_HOME}./bin/plugin install mobz/elasticsearch-head

showdoc

代码地址:https://github.com/star7th/showdoc

docker build -t showdoc ./
docker run -d --name showdoc -p 4999:80 showdoc  `

在浏览器中访问http://xxxx.com:4999/install/

jenkins 迁移

docker load < jenkins.tar
mkdir /data/jenkins
mkdir /data/publish_home
download --> /data/publish_home/jenkins.tar.gz(日志,插件等)
tar -xzvf jenkins.tar.gz(解压)
docker run -d --name myjenkins -u root -p 28080:8080 -v /data/jenkins:/jenkins -v /data/publish_home:/publish_home -v /etc/localtime:/etc/localtime  -v /etc/timezone:/etc/timezone ImagesId

zookeeper

docker pull jeygeethan/zookeeper-cluster
docker run --name docker-zk -d --restart=always \
-p 2181:2181 \
-p 2888:2888 \
-p 3888:3888 \
-v ~/dockerdata/zookeeper/lib:/var/lib/zookeeper \
-v ~/dockerdata/zookeeper/log:/var/log/zookeeper \
-v /etc/localtime:/etc/localtime:ro \
jeygeethan/zookeeper-cluster 47.74.147.198,123.56.93.114,47.104.15.11 1{三台服务器分别1,2,3}

三个节点都启动成功后,进入节点A
docker exec -it docker-zk bash
默认就会进入/usr/share/zookeeper 目录
bin/zkCli.sh
进入了zk的客户端命令行

创建节点 create /nicholas "nicholas"
查看节点 get /nicholas 显示创建成功,
     在虚机B、C上执行get操作检查下新的节点是否已同步,可见则成功。

Kafka

docker run --name docker-kafka -d -p 9092:9092 \
-e KAFKA_HOST=47.74.147.198 \{分别三台ip}
-e KAFKA_PORT=9092 \
-e ZOOKEEPER_CONNECT=47.74.147.198:2181,123.56.93.114:2181,47.104.15.11:2181 \
-e KAFKA_ID=0  \{三台服务器分别 0,1,2}
-v ~/dockerdata/kafka/logs:/tmp/kafka-logs \
-v ~/dockerdata/kafka/data:/vim/ \
jeygeethan/kafka-cluster 

同时进入虚机A,和虚机B

./kafka-topics.sh --create --topic avcdata --partitions 4 --replication-factor 2 \
--zookeeper 47.74.147.198:2181,123.56.93.114:2181,47.104.15.11:2181

./kafka-topics.sh --describe --topic avcdata \
--zookeeper 47.74.147.198:2181,123.56.93.114:2181,47.104.15.11:2181

./kafka-console-producer.sh --topic=avcdata \
--broker-list=47.74.147.198:9092,123.56.93.114:9092,47.104.15.11:9092   

./kafka-console-consumer.sh --topic=avcdata \
--zookeeper 47.74.147.198:2181,123.56.93.114:2181,47.104.15.11:2181 
查看之前 消息,追加参数 --from-beginning

到此,虚机A和B已经都关联上了TP_NIC, 在 A 命令行上,随意输入各类字符, 在 B 上可以看到同样的字符即说明消费成功了.

  • 之后分别修改三个kafka容器中
    {$KAFKA_HOME}:conf/server.properties 文件
    找到
    listeners=PLAINTEXT://:9092
    改为
    listeners=PLAINTEXT://0.0.0.0:9092

portainer

docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /opt/portainer:/data portainer/portainer

评论

发表评论