当前位置:网站首页>Modify the running container port mapping
Modify the running container port mapping
2022-07-28 11:55:00 【Virgocloud】
docker run When you create and run a container , Can pass -p Specify port mapping rules . however , We often encounter that we forget to set the port mapping at the beginning or need to modify it due to the wrong setting . When docker start Running the container does not provide a -p Options or settings , Let you modify the specified port mapping rules . So where should we go in this situation
Method 1 : Delete the original container , Rebuild new containers
The solution is the simplest , Delete the original container , Build a new one . Of course, don't forget to add port mapping this time .
Advantages and disadvantages : The advantage is simple and quick , It is used more in test environment . The disadvantage is that if it's database mirroring , Then rebuild one and reconfigure it again , It's a little bit more complicated .
Method 2 : Modify container profile , restart docker service
Profile path :/var/lib/docker/containers/“ Press tab Key completion ”/hostconfig.json
notes : Stop the container before modifying the configuration file
Modification steps :(vim Open will be messy )
1、vim /var/lib/docker/containers/“ Press tab Key completion ”/hostconfig.json
2、/HostPort Find this place to modify
3、 Save and exit
4、 Restart the service systemctl restart docker
Advantages and disadvantages : The advantage of this method is that there are no side effects , It's easy to operate . The disadvantage is that you need to restart the whole docker service , If there are multiple container services running on the same host , It will affect other container services .
Method 3 : utilize docker commit New mirror image
docker commit: Change the file and configuration information of a container commit To a new mirror . This will be very useful when testing , Import all the file changes and configuration information of the container into a new docker Mirror image , Then use the new image to restart a container , This has no effect on the previous container .
Advantages and disadvantages : The advantage of this approach is that it does not affect other containers on the unified host , The disadvantage is that the management is chaotic , Not as intuitive as the second method .
docker commit course :https://blog.csdn.net/Virgo626249038/article/details/119254784?spm=1001.2014.3001.5501
This article is from 《docker The Chinese community 》 I'll add some content by myself , This article is used for record keeping .
Original text :https://mp.weixin.qq.com/s/9omcc2rq7_nmQnoI3TZpVg
边栏推荐
- 14、用户web层服务(二)
- Design and implementation of SSM personal blog system
- boost官网搜索引擎项目详解
- Final modifier attribute
- 我想请教下各位大佬,cdc采集mysql时,如果发生了主从切换,有什么方案可以处理吗
- ASP. Net core 6 framework unveiling example demonstration [29]: building a file server
- Introduction to web security RADIUS protocol application
- [极客大挑战 2019]BabySQL-1|SQL注入
- Solutions to the disappearance of Jupiter, spyder, Anaconda prompt and navigator shortcut keys
- A natural choice
猜你喜欢

Redis installation

PFP会是数字藏品的未来吗?

A lock faster than read-write lock. Don't get to know it quickly

14. User web layer services (II)

In order to ensure the normal operation of fire-fighting equipment in large buildings, the power supply monitoring system of fire-fighting equipment plays a key role

Zotero document manager and its use posture (updated from time to time)

A hundred flowers bloom in data analysis engines. Why invest heavily in Clickhouse?

Three methods of using unity mouse to drive objects

STL concept and its application
![[general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials](/img/46/830b7703ae7cbfa6051137061560c2.png)
[general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials
随机推荐
How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally
Autumn recruit offer harvesters, and take the offers of major manufacturers at will
[diary of supplementary questions] [2022 Hangdian summer school 2] k-dos card
An example of the mandatory measures of Microsoft edge browser tracking prevention
拥抱开源指南
[pyGame practice] the super interesting bubble game is coming - may you be childlike and always happy and simple~
【补题日记】[2022杭电暑期多校2]K-DOS Card
AlexNet—论文分析及复现
Database advanced learning notes cursor
[diary of supplementary questions] [2022 Niuke summer multi school 2] l-link with level editor I
LabVIEW AI视觉工具包(非NI Vision)下载与安装教程
The reflect mechanism obtains the attribute and method information of class
Specific process of strong cache and negotiation cache
[general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials
async await如何实现并发
中国业务型CDP白皮书 | 爱分析报告
程序的存储态与运行态
Advanced database technology learning notes 1 -- Oracle deployment and pl/sql overview
Leecode8 string conversion integer (ATOI)
保障邮箱安全,验证码四个优势