docker
docker 部署合集
docker搭建OpenLDAP
docker-compose
phpLdapAdmin 创建用户和组
jenkins 集成 ldap
添加memberOf模块
gitlab 集成ldap
OpenLDAP多主复制(基于docker容器模式部署)
ldap 日志
LDAP自助密码服务平台
cadvisor
开放 端口 和 套接字
docker命令
Weave Scope
cmd entrypoint
docker-compose 删除数据卷
docker slim
面试
harbor 更新证书
Docker Build Cache 缓存清理
本文档使用 MrDoc 发布
-
+
首页
docker 部署合集
## mysql /data/mysql/data /data/mysql/logs /data/mysql/conf ``` docker run -d --name mysql \ -v /data/mysql/data:/var/lib/mysql \ -v /data/mysql/conf:/etc/mysql/conf.d \ -v /data/mysql/logs:/logs \ -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=KbAywB5VAeH8smaCf78z mysql:5.7 ``` ## redis wget http://download.redis.io/redis-stable/redis.conf 修改redis.conf配置文件: 主要配置的如下: ``` bind 0.0.0.0 #注释掉这部分,使redis可以外部访问 protected-mode no # 保护模式 daemonize no #用守护线程的方式启动,这里是通过docker部署,所以选择no requirepass 你的密码 #给redis设置密码 ``` ``` docker run -itd -p 6379:6379 --name redis \ -v /data/redis/redis.conf:/usr/local/etc/redis/redis.conf \ -v /data/redis/data:/data \ redis redis-server /usr/local/etc/redis/redis.conf ``` ## minio ``` docker run -d -it \ -p 9000:9000 \ -p 9090:9090 \ --name minio \ -v /data/minio/data:/data \ -e "MINIO_ROOT_USER=admin" \ -e "MINIO_ROOT_PASSWORD=WV4d50eaaK32OBlZlm1s" \ quay.io/minio/minio server /data --console-address ":9090" ``` ## elk ### es ```yaml #elasticsearch.yml cluster.name: "docker-cluster" network.host: 0.0.0.0 xpack.security.enabled: true node.name: node-1 http.cors.enabled: true http.cors.allow-origin: "*" ``` ``` docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" \ -e ES_JAVA_OPTS="-Xms250m -Xmx512m" \ -v /data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ -v /data/elasticsearch/data:/usr/share/elasticsearch/data \ -v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins \ -d elasticsearch:7.8.0 ``` ### kibana ```yaml #kibana.yml server.name: kibana server.host: "0.0.0.0" elasticsearch.hosts: [ "http://192.168.1.58:9200" ] 内网地址 monitoring.ui.container.elasticsearch.enabled: true elasticsearch.username: "kibana_system" elasticsearch.password: "" xpack.security.sessionTimeout: 600000 i18n.locale: "zh-CN" monitoring.enabled: false ``` ``` docker run -d -it --restart=always \ --privileged=true --name=kibana -p 5601:5601 \ -v /data/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml kibana:7.8.0 ``` ### logstash ```yaml http.host: "0.0.0.0" path.config: /usr/share/logstash/config/conf.d/*.conf path.logs: /usr/share/logstash/logs xpack.monitoring.enabled: true xpack.monitoring.elasticsearch.username: logstash_system xpack.monitoring.elasticsearch.password: {密码} xpack.monitoring.elasticsearch.hosts: [ "http://{ip1}:9200","http://{ip2}:9200" ] ``` ``` docker run -dit --name=logstash \ --restart=always --privileged=true\ -e ES_JAVA_OPTS="-Xms512m -Xmx512m" \ -v /data/dockerMount/logstash/conf/logstash.yml:/usr/share/logstash/config/logstash.yml \ -v /data/dockerMount/logstash/conf/conf.d/:/usr/share/logstash/config/conf.d/ \ -p 5044:5044 \ logstash:7.13.2 ``` ## nginx+php 7.3 ``` mkdir -pv /data/nginx /data/php mkdir /data/nignx/conf.d /data/nignx/logs /data/nignx/html mkdir /data/php/phpconf /data/php/fpmconf /data/php/php-fpm.d ``` nginx.conf ``` user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } ``` /data/php/fpmconf/php-fpm.conf ``` ;;;;;;;;;;;;;;;;;;;;; ; FPM Configuration ; ;;;;;;;;;;;;;;;;;;;;; ; All relative paths in this configuration file are relative to PHP's install ; prefix (/usr/local). This prefix can be dynamically changed by using the ; '-p' argument from the command line. ;;;;;;;;;;;;;;;;;; ; Global Options ; ;;;;;;;;;;;;;;;;;; [global] ; Pid file ; Note: the default prefix is /usr/local/var ; Default Value: none ;pid = run/php-fpm.pid ; Error log file ; If it's set to "syslog", log is sent to syslogd instead of being written ; into a local file. ; Note: the default prefix is /usr/local/var ; Default Value: log/php-fpm.log ;error_log = log/php-fpm.log ; syslog_facility is used to specify what type of program is logging the ; message. This lets syslogd specify that messages from different facilities ; will be handled differently. ; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON) ; Default Value: daemon ;syslog.facility = daemon ; syslog_ident is prepended to every message. If you have multiple FPM ; instances running on the same server, you can change the default value ; which must suit common needs. ; Default Value: php-fpm ;syslog.ident = php-fpm ; Log level ; Possible Values: alert, error, warning, notice, debug ; Default Value: notice ;log_level = notice ; Log limit on number of characters in the single line (log entry). If the ; line is over the limit, it is wrapped on multiple lines. The limit is for ; all logged characters including message prefix and suffix if present. However ; the new line character does not count into it as it is present only when ; logging to a file descriptor. It means the new line character is not present ; when logging to syslog. ; Default Value: 1024 ;log_limit = 4096 ; Log buffering specifies if the log line is buffered which means that the ; line is written in a single write operation. If the value is false, then the ; data is written directly into the file descriptor. It is an experimental ; option that can potentionaly improve logging performance and memory usage ; for some heavy logging scenarios. This option is ignored if logging to syslog ; as it has to be always buffered. ; Default value: yes ;log_buffering = no ; If this number of child processes exit with SIGSEGV or SIGBUS within the time ; interval set by emergency_restart_interval then FPM will restart. A value ; of '0' means 'Off'. ; Default Value: 0 ;emergency_restart_threshold = 0 ; Interval of time used by emergency_restart_interval to determine when ; a graceful restart will be initiated. This can be useful to work around ; accidental corruptions in an accelerator's shared memory. ; Available Units: s(econds), m(inutes), h(ours), or d(ays) ; Default Unit: seconds ; Default Value: 0 ;emergency_restart_interval = 0 ; Time limit for child processes to wait for a reaction on signals from master. ; Available units: s(econds), m(inutes), h(ours), or d(ays) ; Default Unit: seconds ; Default Value: 0 ;process_control_timeout = 0 ; The maximum number of processes FPM will fork. This has been designed to control ; the global number of processes when using dynamic PM within a lot of pools. ; Use it with caution. ; Note: A value of 0 indicates no limit ; Default Value: 0 ; process.max = 128 ; Specify the nice(2) priority to apply to the master process (only if set) ; The value can vary from -19 (highest priority) to 20 (lowest priority) ; Note: - It will only work if the FPM master process is launched as root ; - The pool process will inherit the master process priority ; unless specified otherwise ; Default Value: no set ; process.priority = -19 ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. ; Default Value: yes ;daemonize = yes ; Set open file descriptor rlimit for the master process. ; Default Value: system defined value ;rlimit_files = 1024 ; Set max core size rlimit for the master process. ; Possible Values: 'unlimited' or an integer greater or equal to 0 ; Default Value: system defined value ;rlimit_core = 0 ; Specify the event mechanism FPM will use. The following is available: ; - select (any POSIX os) ; - poll (any POSIX os) ; - epoll (linux >= 2.5.44) ; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0) ; - /dev/poll (Solaris >= 7) ; - port (Solaris >= 10) ; Default Value: not set (auto detection) ;events.mechanism = epoll ; When FPM is built with systemd integration, specify the interval, ; in seconds, between health report notification to systemd. ; Set to 0 to disable. ; Available Units: s(econds), m(inutes), h(ours) ; Default Unit: seconds ; Default value: 10 ;systemd_interval = 10 ;;;;;;;;;;;;;;;;;;;; ; Pool Definitions ; ;;;;;;;;;;;;;;;;;;;; ; Multiple pools of child processes may be started with different listening ; ports and different management options. The name of the pool will be ; used in logs and stats. There is no limitation on the number of pools which ; FPM can handle. Your system will tell you anyway :) ; Include one or more files. If glob(3) exists, it is used to include a bunch of ; files from a glob(3) pattern. This directive can be used everywhere in the ; file. ; Relative path can also be used. They will be prefixed by: ; - the global prefix if it's been set (-p argument) ; - /usr/local otherwise include=etc/php-fpm.d/*.conf ``` ``` docker run -itd --name nginx -p 80:80 -p 443:443 \ -v /data/nginx/nginx.conf:/etc/nginx/nginx.conf \ -v /data/nginx/conf.d:/etc/nginx/conf.d \ -v /data/nginx/logs:/var/log/nginx \ -v /data/nginx/html:/usr/share/nginx/html \ -e TZ="Asia/Shanghai" \ nginx:alpine ``` ``` docker run -itd --name php -p 9000:9000 \ -v /data/nginx/html:/var/www/html \ -v /data/php/phpconf:/usr/local/etc/php \ -v /data/php/fpmconf/php-fpm.conf:/usr/local/etc/php-fpm.conf \ -v /data/php/php-fpm.d:/usr/local/etc/php-fpm.d \ php:7.3-fpm-alpine ``` 需要php插件 自行打包安装 ```dockerfile FROM php:7.3-fpm RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install mysqli RUN usermod -u 1001 www-data ``` 权限问题 ``` #创建 www-data 用户 和 组 groupadd www-data useradd -g www-data www-data 授权php挂载的目录 chown -R www-data:www-data ./html/ ``` dockerfile ```dockerfile FROM php:7.3-fpm RUN apt update && apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev && docker-php-source extract RUN docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2 && docker-php-ext-install gd RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install mysqli RUN usermod -u 1001 www-data ``` ### php 安装redis 扩展 ``` redis 扩展下载地址 https://pecl.php.net/package/redis tar zxvf redis-5.3.4.taz 解压redis 扩展包 docker cp redis-5.3.4 php:/usr/src/php/ext/redis docker-php-ext-install redis ``` ## mongo ``` docker run -it --name mongodb \ -e MONGO_INITDB_ROOT_USERNAME=mongoroot \ -e MONGO_INITDB_ROOT_PASSWORD=QzgPunaCkNZM6oXdBf9I \ -v /opt/mongo:/data/db \ -p 27017:27017 -d mongo ``` ## alpine ``` FROM alpine:3.14 # 设置阿里云镜像源 RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories && \ echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories RUN apk update && apk upgrade # 安装glibc 2.34 RUN apk add --no-cache wget ca-certificates && \ wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \ wget -q -O glibc.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-2.34-r0.apk && \ apk add glibc.apk && \ rm glibc.apk VOLUME /data/service/ CMD ["tail", "-f", "/dev/null"] #CMD["sh","-c","command"] ``` ## jenkins ``` docker run -d -uroot -p 9095:8080 -p 50000:50000 --name jenkins \ -v /home/jenkins_home:/var/jenkins_home \ -v /etc/localtime:/etc/localtime \ -v /run/docker.sock:/var/run/docker.sock \ -v /usr/bin/docker:/usr/bin/docker \ --restart=always \ jenkins/jenkins:lts docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword ```
admin
2024年8月22日 15:26
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码