Modify the rancher container service mapping port

Here are the steps on how to modify the port if rancher is already installed:

  1. Firstdocker stop 要修改配置的容器id

  2. View /var/lib/docker/containers/[hash_of_the_container]/hostconfig.jsonthe file, where hashofthecontainer is the hash value of the docker image, which can be viewed through docker ps or docker inspect containername. (The CONTAINER ID can be seen)
    insert image description here
    As shown in the figure above, one of the items in the file is PortBindings, where 8080/tcp corresponds to port 8080 inside the container, and HostPort corresponds to port 9190 mapped to the host. 8361/tcp corresponds to Port 8361 inside the container, and HostPort corresponds to port 9191 mapped to the host. Modify the port as needed, then restart the docker service, and then start the container service.
    systemctl restart docker

Note: docker stop container id will be modified successfully, otherwise it will still be the original port after restarting docker.
Description: The advantage of this method is that it has no side effects and is easy to operate. The disadvantage is that the entire docker service needs to be restarted. If multiple container services are running on the same host, other container services will be affected.

Guess you like

Origin blog.csdn.net/changlina_1989/article/details/120724159
Recommended