Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

docker简易使用流程[0]

Posted on 2023年11月14日 by

本篇是docker常用命令的续篇

docker pull centos:centos7 #拉取镜像
docker run -it -d --name centos_test centos:centos7  /bin/bash 启动docker容器并后台运行
将docker端口和主机端口进行绑定

systemctl restart firewalld
docker run -it -d -p 80:80  centos:centos7  /bin/bash #绑定80端口到主机

#安装nginx
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum -y install nginx

exit #此处会退出docker

docker ps #获取镜像id
docker start 91ae2a688fbe #重新启动daokcer镜像
docker exec -it 91ae2a688fbe  /bin/bash #本次退出不会停止容器
docker attach 91ae2a688fbe #获取镜像id
/usr/sbin/nginx -c /etc/nginx/nginx.conf 启动nginx
exit

效果验证:

补充说明:制作新的镜像

exit #退出docker容器
docker start 28f8859144fe  #启动docker容器
docker commit centos_test centos/nginx #更改容器
docker images centos/nginx #将容器转换成镜像
docker images centos/nginx #查询镜像

参考资料:

  1. https://cloud.tencent.com/developer/article/1667555

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT