合 PG官方docker镜像使用Debian系统添加中文排序+ssh支持
Tags: PGPostgreSQLdocker镜像Debian
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | docker rm -f pgtmp docker run --name pgtmp -h pgtmp -itd -p 221:22 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai -e POSTGRES_INITDB_ARGS="--data-checksums" postgres:15.4 docker exec -it pgtmp bash cat > /etc/apt/sources.list <<"EOF" deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free EOF apt-get update -y && apt-get upgrade -y apt install -y initscripts net-tools telnet wget openssh-server iputils-ping sudo vim echo "PermitRootLogin yes" >> /etc/ssh/sshd_config echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config echo "root:lhr" | chpasswd mkdir /run/sshd chmod 0755 /run/sshd nohup /usr/sbin/sshd -D & localedef -c -f UTF-8 -i en_US en_US.UF8 localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 localedef -c -f UTF-8 -i zh_CN zh_CN.gbk localedef -c -f UTF-8 -i zh_CN zh_CN.gb18030 localedef -c -f UTF-8 -i zh_CN zh_CN.gb2312 locale -a | grep zh_CN docker commit pgtmp pg15.4:1.0 docker rm -f pgtmp docker run --name pgtmp -h pgtmp -itd -p 221:22 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai -e POSTGRES_INITDB_ARGS="--data-checksums" --privileged=true pg15.4:1.0 init docker exec -it pgtmp bash systemctl disable user@999.service systemctl mask user@999.service systemctl stop getty@tty1.service systemctl mask getty@tty1.service mkdir -p /home/postgres chown postgres:postgres /home/postgres -R sed -i 's|/var/lib/postgresql|/home/postgres|' /etc/passwd echo "postgres:lhr" | chpasswd echo "postgres ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers su - postgres rm -rf /var/lib/postgresql/data/ /usr/lib/postgresql/15/bin/initdb -D /var/lib/postgresql/data -E UTF8 --locale=zh_CN.UTF-8 -U postgres --data-checksums /usr/lib/postgresql/15/bin/pg_ctl -D /var/lib/postgresql/data start cat >> /home/postgres/.bash_profile <<"EOF" export LANG=zh_CN.UTF-8 export PS1="[\u@\h \W]\$ " export PGPORT=5432 export PGDATA=/var/lib/postgresql/data export PGHOME=/usr/lib/postgresql/15 export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH export PATH=$PGHOME/bin:$PATH:. export DATE=`date +"%Y%m%d%H%M"` export MANPATH=$PGHOME/share/man:$MANPATH export PGHOST=$PGDATA export PGUSER=postgres export PGDATABASE=postgres EOF source /home/postgres/.bash_profile |