一个容器运行多个服务案例(nginx+sshd) docker
docker手动制作容器镜像: https://www.baimeidashu.com/10674.html
1.基于上一篇 启动的nginx镜像为基础镜像
docker exec -it silly_visvesvaraya bash
[root@1b4669019a3d /]# yum provides sshd # 判断sshd属于哪个软件包
[root@1b4669019a3d /]# yum -y install openssh-server initscripts # 安装opssh-server软件包
cat /start.sh
#!/bin/bash
# Inint root password.
if [ -n "$ADMIN_PASSWD" ];then
echo $ADMIN_PASSWD | passwd root --stdin
elif [ -n "$1" ]; then
echo $1 | passwd root --stdin
else
echo 123 | passwd root --stdin
fi
# start nginx server
# nginx -g "daemon off;"
nginx
# get key
/usr/sbin/sshd-keygen
# start sshd service
/usr/sbin/sshd -D
2.提交镜像并启动yum容器
docker commit silly_visvesvaraya baimei-centos-nginx:v0.3
[root@centos201 ~]# docker commit silly_visvesvaraya baimei-centos-nginx:v0.3
[root@centos201 ~]# docker run -dp 1180:80 -p 1122:22 baimei-centos-nginx:v0.3
[root@centos201 ~]# docker run -dp 1180:80 -p 1122:22 baimei-centos-nginx:v0.3 bash -x /start.sh 666
[root@centos201 ~]# docker run -dp 2280:80 -p 2222:22 -e ADMIN_PASSWD=888 baimei-centos-nginx:v0.3
[root@centos201 ~]# docker run -dp 3380:80 -p 3322:22 -e ADMIN_PASSWD=888 baimei-centos-nginx:v0.3 bash -x /start.sh 666
欢迎来撩 : 汇总all