How to modify docker container port

王林
Release: 2020-07-03 17:14:09
forward
5500 people have browsed it

How to modify docker container port

The modification method is as follows:

(Recommended learning: docker tutorial)

1. Stop the container

2. Stop the docker service

systemctl stop docker
Copy after login

3. Modify the port in the hostconfig.json file of this container (if the port is also recorded in config.v2.json, you must also modify it)

cd /var/lib/docker/3b6ef264a040*  #这里是CONTAINER ID
Copy after login
vi hostconfig.json
Copy after login

If there is no port mapping before, there should be a paragraph like this: "PortBindings":{}

Add a mapping like this: "PortBindings":{"3306/tcp":[{"HostIp":"" ,"HostPort":"3307"}]}

The first number is the container port, and the latter number is the host port. Modifying the existing port mapping is simpler, just change the port number.

4. Start the docker service

systemctl start docker
Copy after login

5. Start the container

The above is the detailed content of How to modify docker container port. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template