DEV Community

loading...
Cover image for How to open/edit/bind ports to running Docker Containers

How to open/edit/bind ports to running Docker Containers

Joseph Peculiar
Fullstack Software / Blockchain Engineer
・1 min read

You have a running production container (a synced node) and you would want to either edit or bind new ports in this container, as opposed to spinning up a new container.

The following steps should aid you to achieve this.

1.Stop the running Container

docker stop <container-id>

2.Open Docker containers directory

cd /var/lib/docker/containers/

cd <container-id>

Alt Text

3.Edit hostconfig.json

Open hostconfig.json with nano or vim
locate and edit PortBindings with the new ports you want to edit, open or delete.

for instance

"PortBindings":{"18332/tcp":[{"HostIp":"","HostPort":"18332"}],"18334/tcp":[{"HostIp":"","HostPort":"18334"}]}

4.Restart Docker

systemctl restart docker

5.Start container

docker start <container-id>

Discussion (0)