Skip to main content

Software Containers (docker)

Database Typed

MySQL

5.7

docker run \
--name mysql57 \
-e MYSQL_ROOT_PASSWORD=root \
-e TZ=Asia/Shanghai \
-p 3306:3306 \
-v /app/mujup/mysql5.7/data:/var/lib/mysql \
-v /app/mujup/mysql5.7/config:/etc/mysql/conf.d \
-v /app/mujup/mysql5.7/logs:/logs \
-d mysql:5.7

8

docker run \
--name mysql-8 \
-e MYSQL_ROOT_PASSWORD=root \
-e TZ=Asia/Shanghai \
-p 3306:3306 \
-v /usr/local/applications/mysql/data:/var/lib/mysql \
-v /usr/local/applications/mysql/config:/etc/mysql/conf.d \
-v /usr/local/applications/mysql/logs:/logs \
-d mysql:8

Mariadb

docker run --detach \
-p 3306:3306 \
--name mariadb \
--env MARIADB_USER=maria \
--env MARIADB_PASSWORD=root \
--env MARIADB_ROOT_PASSWORD=root mariadb:10.7

MongoDB

docker run -d --name mongo -p 27017:27017 \
-v /app/mongo/data/db:/data/db \
-v /app/mongo/data/configdb:/data/configdb \
-e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=123456 \
mongo --auth

Clickhouse

docker run -d -p 18123:8123 -p 19000:9000 --name clickhouse-server \
-v $(realpath ./ch_data):/var/lib/clickhouse/ \
-v $(realpath ./ch_logs):/var/log/clickhouse-server/ \
-v /path/to/your/config.xml:/etc/clickhouse-server/config.xml \
-e CLICKHOUSE_DB=my_database \
-e CLICKHOUSE_USER=clickhouse \
-e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 \
-e CLICKHOUSE_PASSWORD=clickhouse \
registry.dockermirror.com/clickhouse/clickhouse-server

PostgresSQL

PostgresSQL Exporter

docker run -d \
-p 9187:9187 \
-e DATA_SOURCE_NAME="postgresql://enterprisedb:yyy&[email protected]:5432/adb?sslmode=disable" \
quay.io/prometheuscommunity/postgres-exporter

K/V Typed

Redis5

docker run --name redis-5 -d -p 6379:6379 redis:5 redis-server --appendonly yes --requirepass 'password'
  • -p 6379:6379: 将容器内端口映射到宿主机端口(右边映射到左边)
  • redis-server –appendonly yes: 在容器执行redis-server启动命令,并打开redis持久化配置
  • requirepass “your passwd”: 设置认证密码
  • –restart=always: 随docker启动而启动

Message Typed

RabbitMQ

docker run -d -p 5672:5672 -p 15672:15672 --hostname some-hostname --name some-rabbit rabbitmq:3-management
  • -p 5672:5672 AMQP的server监听端口
  • -p 15672:15672 管理面板端口,(默认账号密码:guest guest)

Kafka

  1. pull images
docker pull wurstmeister/zookeeper
docker pull wurstmeister/kafka
  1. run zk
docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper
  1. run kafka

192.168.50.252 改为宿主机器的IP地址,如果不这么设置,可能会导致在别的机器上访问不到kafka。
默认目录: /opt/kafka_2.11-0.10.1.0

docker run -d \
--name kafka \
--publish 9092:9092 \
--link zookeeper \
--env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
--env KAFKA_ADVERTISED_HOST_NAME=192.168.50.252 \
--env KAFKA_ADVERTISED_PORT=9092 \
--volume /etc/localtime:/etc/localtime wurstmeister/kafka:latest

MicroService Infrastructure Typed

Docker registry

docker run -d -p 5000:5000 --name registry-2.7 --restart=always -v /app/docker-registry:/var/lib/registry registry:2.7.1

Docker registry WEB GUI

docker run -d -p 5001:8080 --name registry-web --link registry-2.7 -e REGISTRY_URL=http://registry-2.7:5000/v2 -e REGISTRY_NAME=localhost:5000 hyper/docker-registry-web:v0.1.2
  • -e REGISTRY_NAME=localhost:5000 localhost 可以设定为 docker 主机 ip 使用起来会更方便

Artifactory

8082 是 ui 的端口

docker pull docker.bintray.io/jfrog/artifactory-oss

docker run --rm --name artifactory -d
-v artifactory_data:/var/opt/jfrog/artifactory
-p 8081:8081 -p 8082:8082 docker.bintray.io/jfrog/artifactory-oss

Consul

8500 为 ui 的端口

docker run -d --name=dev-consul -e CONSUL_BIND_INTERFACE=eth0 -p  8500:8500 -p 8300:8300 -p 8301:8301 -p 8302:8302 -p 8600:8600 consul

MinIO

默认 key: minioadmin

docker run -d --name minio -p 9000:9000 -v /app/minio/:/data minio/minio server /data
  • -e MINIO_ROOT_USER=minio (AK)
  • -e MINIO_ROOT_PASSWORD=minpassword (SK)

Untags

OneDev

docker run --name onedev -d \
--restart always \
-v <host docker sock>:/var/run/docker.sock \
-v <data dir>:/opt/onedev \
-p 6610:6610 \
-p 6611:6611 \
1dev/server

youtransfer

docker run -d -p 5050:5000 --name youtransfer --restart=always -v /tmp/youtransfer/uploads:/opt/youtransfer/uploads remie/youtransfer:stable