docker-compose.yml 配置
version: "3"
services:
gitserver:
image: quay.io/centos/centos:stream8
container_name: gitserver
entrypoint: /entrypoint.sh
working_dir: /root
volumes:
- ./data/gitrepo:/git
- ./entrypoint.sh:/entrypoint.sh
- /etc/localtime:/etc/localtime
privileged: true
user: root
network_mode: outside-world
ports:
- 53222:22
entrypoint.sh 脚本
#!/bin/bash
if [ ! -f "/init.tag" ] ; then
yum install -y openssh-server
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key
adduser git
touch /init.tag
fi
chown git:git /git -R
exec /usr/sbin/sshd -D
#yum install -y git
#python3 -m venv /root/workspace/venv
#source /root/workspace/venv/bin/activate
#yum install -y libgomp libquadmath
#pip install d2l mxnet pandas matplotlib -i https://pypi.douban.com/simple/ --trusted-host pypi.douban.com
if [ $# -gt 0 ] ; then
${@}
exit 0
fi
while true ; do
sleep 10
done