# Docker edit container parameter after

**URL:** <https://www.wago.community/t/docker-edit-container-parameter-after/749>\
**Category:** Hardware and Linux\
**Tags:** docker\
**Created:** [January 22, 2024, 2:51am UTC](https://www.wago.community/t/docker-edit-container-parameter-after/749 "2024-01-22T02:51:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WagoIcard](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagoicard/32/1508_2.png) [@WagoIcard](https://www.wago.community/u/WagoIcard)\
**Post date:** [January 22, 2024, 2:51am UTC](https://www.wago.community/t/docker-edit-container-parameter-after/749/1 "2024-01-22T02:51:02Z")

</div>

Have you ever created a container avec after some testing found out you forgot to do some port forwarding ?  
Here is how to fix this without having to recreate the container:

1. Get the container ID: `docker ps -a`

2. Stop the container: `docker stop [container name]`

3. Stop the docker: `/etc/init.d/dockerd stop` (or for generic linux: `systemctl stop docker`)

4. Edit the container `config.v2.json` file, found at `home/docker/containers/[container ID]/config.v2.json`

5. Within the `ExposedPorts` section, either edit the existing ports to the port you would like, or add them yourself. For example adding UDP port 1202:

```JSON
"ExposedPorts":{"1880/tcp":{}},

```

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to

```JSON
"ExposedPorts":{"1880/tcp":{},"1202/udp":{}},

```

1. Within the `Ports` section, either edit the existing ports and `HostPort` to the port you would like, or add them yourself. For example adding UDP port 1202:

```JSON
"Ports":{"1880/tcp":[{"HostIp":"0.0.0.0","HostPort":"1880"}]},

```

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to

```JSON
"Ports":{"1880/tcp":[{"HostIp":"0.0.0.0","HostPort":"1880"}],"1202/udp":[{"HostIp":"0.0.0.0","HostPort":"1202"}]},

```

1. **Save** and exit the config file

2. Edit the container `hostconfig.json` file, found at `home/docker/containers/[container ID]/hostconfig.json`.

3. Within the `PortBindings` section, either edit the existing ports and `HostPort` to the port you would like, or add them yourself. For example adding UDP port 1202:

```JSON
"PortBindings":{"1880/tcp":[{"HostIp":"","HostPort":"1880"}]},

```

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to

```JSON
"PortBindings":{"1880/tcp":[{"HostIp":"","HostPort":"1880"}],"1202/udp":[{"HostIp":"","HostPort":"1202"}]},

```

1. **Save** and exit the config file

2. Reboot the PLC

`Original infomation:`

> **[Docker Change Port Mapping for an Existing Container](https://mybrainimage.wordpress.com/2017/02/05/docker-change-port-mapping-for-an-existing-container/)**
>
> How to change port mapping for an existing docker container.
