# Docker - How to Edit Bind Exist Container Ports to the Host

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1638549184826/M9XvD115C.png align="left")

We have this running container, and wa re going to change the binded container port from 9212 to 9200.

#### 1\. Stop running container.

Stop the running container which you want to edit, in my case it is `mgt-dev-71`. So I run this command :

```bash
docker stop mgt-dev-71
```

#### 2\. Go to docker containers directory.

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](https://s.id/1GOQk)

#### 3\. Edit hostconfig.json.

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.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1638504851627/qaFdgHME-.png align="left")

Then, find `PortBindings` like in the picture below.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1638504866906/0NJgeEPnF.png align="left")

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.

```bash
"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.

#### 4\. Restart docker service.

```bash
systemctl restart docker
```

in Windows or Mac, you need to restart docker machine.

#### 5\. Start container.

```bash
docker start mgt-dev-71
```

---

**Voila…** You just point port 8080 of your host to docker container.
