1 mysql

  1. docker pull mysql:8.0.26
  2. docker run -d --name mysql8 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v ~/DockerDir/mysql/:/etc/mysql/conf.d mysql:8.0.26
  1. # mysql下的是MySQL客户端的配置
  2. [mysql]
  3. # mysqld下的是MySQL服务端的配置
  4. [mysqld]
  5. user = mysql
  6. port = 3306
  7. pid-file = /var/run/mysqld/mysqld.pid
  8. socket = /var/run/mysqld/mysqld.sock
  9. # 允许连接的IP地址, 注释掉之后所有IP的机器都可以连接本MySQL服务端
  10. # bind-address = 127.0.0.1
  11. # 指定单个查询能够使用的缓冲区大小
  12. key_buffer_size = 16M

2 redis

  1. docker pull redis
  2. docker run -d --name redis1 -p 6379:6379 -v ~/DockerDir/redis:/etc/redis redis redis-server /etc/redis/redis.conf
  1. # 接收来自0.0.0.0网卡的请求
  2. bind 0.0.0.0
  3. # 不启用保护模式, 外界可访问
  4. protected-mode no
  5. # redis-server绑定的端口号
  6. port 6379
  7. # 设置认证密码
  8. requirepass redis123!
  9. # redis-server后台运行
  10. daemonize no
  11. # 工作目录
  12. dir ./
  13. # RDB配置
  14. save 900 1
  15. save 300 10
  16. save 60 10000
  17. dbfilename dump.rdb
  18. # AOF配置
  19. appendonly yes
  20. appendfilename "appendonly.aof"

3 mongo

  1. docker pull mongo:4.4.13
  2. docker run -d --name mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=mongo123 mongo:4.4.13

4 kafka

  1. docker pull wurstmeister/zookeeper
  2. docker pull wurstmeister/kafka
  3. docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper
  4. docker run --name kafka1 \
  5. -p 9092:9092 \
  6. -e KAFKA_BROKER_ID=0 \
  7. -e KAFKA_ZOOKEEPER_CONNECT=内网IP:2181 \
  8. -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://公网IP:9092 \
  9. -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \
  10. -d wurstmeister/kafka
  11. docker run --name kafka2 \
  12. -p 9093:9093 \
  13. -e KAFKA_BROKER_ID=1 \
  14. -e KAFKA_ZOOKEEPER_CONNECT=内网IP:2181 \
  15. -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://公网IP:9093 \
  16. -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9093 \
  17. -d wurstmeister/kafka

5 nginx

  1. server {
  2. listen 80;
  3. server_name localhost;
  4. location /static/ {
  5. alias /home/;
  6. }
  7. }
  1. docker pull nginx
  2. docker run -d --name nginx1 -p 80:80 \
  3. -v /home/nginx_conf:/etc/nginx/conf.d \
  4. -v /home:/home \
  5. nginx

0 附:解决docker镜像pull慢

  1. vi /etc/docker/daemon.json
  1. {
  2. "registry-mirrors" : ["https://docker.mirrors.ustc.edu.cn"]
  3. }
  1. service docker restart