返回
Featured image of post Docker常用镜像整理

Docker常用镜像整理

前言

项目开发经常需要临时安装个数据库,安装工具,搭建一套测试环境什么的。直接在服务器上安装,会有很多插件依赖库慢慢的拖慢服务器。使用Docker安装是个非常不错的主意。以下是我整理自用的Docker项目,供大家参考学习。

Docker项目

  1. docker安装postgres数据库
mkdir -p /root/waline/postgresql/data
docker run -d \
  -v /root/waline/postgresql/data:/var/lib/postgresql/data \
  -e POSTGRES_PASSWORD=postgres \
  -p 127.0.0.1:5432:5432 \
  --name postgres \
  postgres

#查看容器虚拟IP地址
docker inspect postgres |grep IPAddress

#pg执行SQL文件
docker exec -it postgres /bin/bash
psql -U postgres -d postgres -h 172.17.0.3 -p 5432 -f xx.sql
  1. docker安装ssr服务器
docker run -p 51348:51348 \
  --restart=always \
  --name=SSR \
  -e PASSWORD=passw0rd \
  -e METHOD=chacha20-ietf \
  -e PROTOCOL=auth_sha1_v4 \
  -e OBFS=tls1.2_ticket_auth \
  -d breakwa11/shadowsocksr
  1. docker安装waline评论系统
docker run -d \
  -e PG_DB=postgres \
  -e PG_USER=postgres \
  -e PG_PASSWORD=postgres \
  -e PG_HOST=172.17.0.3 \ 
  -e PG_PORT=5432 \
  -e TZ=Asia/Shanghai \
  -p 127.0.0.1:8360:8360 \
  --name=waline \
  lizheming/waline:1.31.5
  1. docker安装it-tools工具集合
docker run -d \
  --name it-tools 
  --restart unless-stopped \
  -v /root/it-tools/html:/usr/share/nginx/html \
  -p 127.0.0.1:6005:80 \
  ghcr.io/corentinth/it-tools:latest

# nginx配置反向代理
server {
    if ($request_method !~* GET|POST) {
        return 403;
    }
    listen 443 ssl;
    ssl_certificate     /home/xiaoming/demo.crt; #证书
    ssl_certificate_key /home/xiaoming/demo.key; #密钥
    charset utf-8;

    #it-tools工具集
    location /it-tools/ {
        rewrite ^/it-tools/(.*) /$1 break;
        proxy_pass http://127.0.0.1:6005;
    }
}
  1. docker安装homeassistant
mkdir -p /root/config

docker run -d -p 8123:8123 --restart=always \
  --name=homeAssistant.2023.6 \
  -v /root/config:/config \
  -e TZ=Asia/Shanghai \
  --privileged=true \
  --net=host \
  homeassistant/raspberrypi3-homeassistant:stable
  1. docker安装mqtt服务器
mkdir -p /root/mosquitto/config
mkdir -p /root/mosquitto/data
mkdir -p /root/mosquitto/log

vi /root/mosquitto/config/mosquitto.conf
persistence true
persistence_location /mosquitto/data
log_dest file /mosquitto/log/mosquitto.log
bind_address 0.0.0.0
port 1883

chmod -R 755 /root/mosquitto

docker run -d \
  --net="host" \
  --name=mosquitto \
  --restart=always \
  --privileged \
  -e TZ="Asia/Shanghai" \
  -p 1883:1883 \
  -p 9001:9001 \
  -v /root/mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto.conf \
  -v /root/mosquitto/data:/mosquitto/data \
  -v /root/mosquitto/log:/mosquitto/log \
  eclipse-mosquitto


1)、配置文件添加以下配置
# 关闭匿名模式
allow_anonymous false
# 指定密码文件
password_file /mosquitto/config/pwfile.conf

2)、进入容器
docker exec -it mosquitto sh

3)、生成密码(在容器内执行)
#对于passworf_file,可以复制一份模板,或者创建一个空文件
touch /mosquitto/config/pwfile.conf
chmod -R 755 /mosquitto/config/pwfile.conf
# 使用mosquitto_passwd命令创建用户,第一个lxy是用户名,第二个lxy是密码
mosquitto_passwd -b /mosquitto/config/pwfile.conf hass hass
  1. doccker安装博客typecho
mkdir /root/typecho
#chmod -R user:user /root/typecho  #依稀记得要给权限
docker run \
  --name typecho \
  -p 6002:80 \
  -v /root/typecho:/app \
  -e TYPECHO_SITE_URL=https://www.demo.com \
  -d joyqi/typecho:nightly-php7.4-apache
  1. docker安装chrome浏览器(实际就是linux系统默认启动chrome)
docker run -d \
  --name chrome \
  -e LANG=en_US.UTF-8 \
  -e LANGUAGE=en_US.UTF-8 \
  -e LC_ALL=C.UTF-8 \
  -e TZ=Asia/Shanghai \
  -e SCREEN_RESOLUTION=1280x720 \
  -p 8083:8083 \
  -p 5900:5900 \
  oldiy/chrome-novnc:latest

总结

先就这些吧,以后有新内容加添加。希望对各位有帮助。

Licensed under CC BY-NC-SA 4.0