当前位置:网站首页>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
边栏推荐
- Deployment and use of Minio distributed object storage
- A natural choice
- 可视化大型时间序列的技巧。
- [diary of supplementary questions] [2022 Hangdian summer school 2] k-dos card
- A new mode of one-stop fixed asset management
- Four advantages of verification code to ensure mailbox security
- Techniques for visualizing large time series.
- Cvpr2020 best paper: unsupervised learning of symmetric deformable 3D objects
- How to effectively implement a rapid and reasonable safety evacuation system in hospitals
- consul安装与配置
猜你喜欢

直接插入排序与希尔排序

Localization, low latency, green and low carbon: Alibaba cloud officially launched Fuzhou data center

可视化大型时间序列的技巧。

How to effectively implement a rapid and reasonable safety evacuation system in hospitals
![[geek challenge 2019] babysql-1 | SQL injection](/img/21/b5b4727178a585e610d743e92248f7.png)
[geek challenge 2019] babysql-1 | SQL injection

Consumer installation and configuration

Will PFP be the future of digital collections?

Shell (I)

Detailed explanation of boost official website search engine project

「以云为核,无感极速」第五代验证码重磅来袭
随机推荐
[diary of supplementary questions] [2022 Niuke summer multi school 2] D-Link with game glitch
【补题日记】[2022牛客暑期多校2]L-Link with Level Editor I
移动端人脸风格化技术的应用
一文看懂设备指纹如何防篡改、防劫持
程序的存储态与运行态
R language uses dplyr package group_ By function and summarize function calculate the mean value of all covariates involved in the analysis based on grouped variables (difference in means of covariate
Solutions to slow start of MATLAB
Specific process of strong cache and negotiation cache
14、用户web层服务(二)
【MySQL】Got an error reading communication packets
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
PFP会是数字藏品的未来吗?
Anonymous subclass objects of abstract classes
I want to ask you guys, if there is a master-slave switch when CDC collects mysql, is there any solution
Why does acid food hurt teeth + early periodontitis
R language - some metrics for unbalanced data sets
Has samesite cookies ever occurred when using identityserver?
ASP. Net core 6 framework unveiling example demonstration [29]: building a file server
Start from scratch blazor server (2) -- consolidate databases
业务可视化-让你的流程图'Run'起来(4.实际业务场景测试)