一、拉取镜像
docker pull hub.c.163.com/library/centos
二、生成临时镜像
# 启动镜像
docker run -d -it -p 8888:8888 hub.c.163.com/library/centos
# 进入容器
docker exec -it 容器ID bash
# 执行宝塔面板Centos安装命令:
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh
# 安装成功
==================================================================
Bt-Panel: http://X.X.X.X:8888
username: wtaudjmy
password: 87b84184
Warning:
If you cannot access the panel,
release the following port (8888|888|80|443|20|21) in the security group
==================================================================
# 将容器保存为一个新的镜像
docker commit 容器ID yht/centos/baota:tmp
三、编写 Dockerfile 文件
nano Dockerfile
-----------------------------------------------------------------------------------------
FROM yht/centos/baota:tmp
MAINTAINER yanghaiteng 13702721963@139.com
EXPOSE 22122 23000 8080 9999
COPY docker-entrypoint.sh /usr/bin/
RUN chmod 777 /usr/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
CMD [""]
-----------------------------------------------------------------------------------------
四、编写 docker 容器启动文件
nano docker-entrypoint.sh
-----------------------------------------------------------------------------------------
#!/bin/bash
/etc/init.d/bt start
while [ 0 -lt 1 ]
do
sleep 3600s
done
-----------------------------------------------------------------------------------------
五、执行 Dockerfile 制作镜像
docker build -t yht/centos/baota .
六、镜像的使用
docker run -d -it \
--name baota \
--restart unless-stopped \
-p 8888:8888 \
yht/centos/baota
firewall-cmd --permanent --add-port=8888/tcp
firewall-cmd --reload
firewall-cmd --list-all
# 停止
/etc/init.d/bt stop
# 启动
/etc/init.d/bt start
# 重启
/etc/init.d/bt restart
最后修改:2019-11-09 16:25:51
© 著作权归作者所有
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

发表评论