Docker - How to Edit Bind Exist Container Ports to the Host
I wrote these tutorials for myself in future when I forget for the next steps.
Search for a command to run...
I wrote these tutorials for myself in future when I forget for the next steps.
No comments yet. Be the first to comment.
When you provision an Ubuntu instance on Oracle Cloud, you'll notice something different from standard Ubuntu installations: the system uses iptables instead of ufw for firewall management. This disti

When developing web applications locally, HTTPS is often overlooked. Yet, modern browsers and APIs increasingly require secure connections—even in development. That’s where mkcert comes in: a simple t

Testing the checkout success page in Magento 2 can be frustrating. By default, once an order is placed, Magento clears the quote session, meaning you can’t simply refresh or revisit the success page without going through the entire checkout process a...

Magento Commerce (EE) offers powerful features, but for many teams, Open Source (CE) is leaner, lighter, and more sustainable. If you're migrating from EE to CE, the Opengento downgrade tool provides a clean, scriptable way to remove proprietary modu...

If you’ve ever checked your Apache error logs and seen something like this: Code [core:error] (13)Permission denied: access to /robots.txt denied (filesystem path '/home/username/sites') because search permissions are missing on a component of the pa...


We have this running container, and wa re going to change the binded container port from 9212 to 9200.
Stop the running container which you want to edit, in my case it is mgt-dev-71. So I run this command :
docker stop mgt-dev-71
For linux open up your terminal and go to /var/lib/docker/containers/
For windows or linux, you can follow this step to access /var/lib/docker/containers/ : https://fiko.me/docker-how-to-access-docker-mobylinux-vm-on-windows-or-mac
Change directory to where your container directory which is the container ID. In my case, it is 610d6949f329.
Edit hostconfig.json via nano or vim editor, you will find such long one line like this one.

Then, find PortBindings like in the picture below.

And add or edit to PortBindings, in my case I would like to port 8080 of my computer to port 80 of this container. So it would be like this.
"PortBindings":{"80/tcp":[{"HostIp":"","HostPort":"8080"}], "22/tcp":[{"HostIp":"","HostPort":"22"}], "3306/tcp": ......}
80 : is port in container.
8080 : is port in computer/host that will be pointed to port 80 of container.
systemctl restart docker
in Windows or Mac, you need to restart docker machine.
docker start mgt-dev-71
Voila… You just point port 8080 of your host to docker container.