Docker port is bound but is not accessable

I am running 2 docker images (in another docker image)

docker run --name first -d -p 8000:8000 ${first}
docker run --name vault_c -d -p 8200:8200 --cap-add=IPC_LOCK -e “VAULT_DEV_ROOT_TOKEN_ID=myroot” -e “VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200” vault

The second image is the hashicorp vault image.

When I try to curl both of them

$ curl 127.0.0.1:8000/documentation/index.html || true

 % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
<!DOCTYPE html>
...
$ curl 127.0.0.1:8200/v1/sys/metrics || true

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

curl: (56) Recv failure: Connection reset by peer

Docker inspect for the first image show:

$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' first

8000/tcp -> 8000

Docker inspect for vault shows:

$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' vault_c

8200/tcp -> 8200

Complete docker inspect

$ docker inspect first

Output
[
    {
        "Id": "bdb0cb3b8be2d9d60dab316fb6c28c6240de9d0a3eb8ab8417aeb9233eca55ca",
        "Created": "2022-02-10T08:12:27.500136227Z",
        "Path": "./first",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 280,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-02-10T08:12:29.793767565Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:ae8dc4bf665a9f3de78a66db059b0477de1fea829cc324391212105e6c1757c1",
        "ResolvConfPath": "/var/lib/docker/containers/bdb0cb3b8be2d9d60dab316fb6c28c6240de9d0a3eb8ab8417aeb9233eca55ca/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/bdb0cb3b8be2d9d60dab316fb6c28c6240de9d0a3eb8ab8417aeb9233eca55ca/hostname",
        "HostsPath": "/var/lib/docker/containers/bdb0cb3b8be2d9d60dab316fb6c28c6240de9d0a3eb8ab8417aeb9233eca55ca/hosts",
        "LogPath": "/var/lib/docker/containers/bdb0cb3b8be2d9d60dab316fb6c28c6240de9d0a3eb8ab8417aeb9233eca55ca/bdb0cb3b8be2d9d60dab316fb6c28c6240de9d0a3eb8ab8417aeb9233eca55ca-json.log",
        "Name": "/es",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "8000/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8000"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/00f86eff6dbeb3c404dcf282ba9ec9fb39977cded61cd5d94f78c23d1db3cd53-init/diff:/var/lib/docker/overlay2/0dc3c4c9a31888adf107e992f4e46ef7c6a75f2ccd1a3bd190c6e0bcf59696f2/diff:/var/lib/docker/overlay2/cb8994066d329e17c522a267787813be682454e5f515d34091311c502de3a4b7/diff",
                "MergedDir": "/var/lib/docker/overlay2/00f86eff6dbeb3c404dcf282ba9ec9fb39977cded61cd5d94f78c23d1db3cd53/merged",
                "UpperDir": "/var/lib/docker/overlay2/00f86eff6dbeb3c404dcf282ba9ec9fb39977cded61cd5d94f78c23d1db3cd53/diff",
                "WorkDir": "/var/lib/docker/overlay2/00f86eff6dbeb3c404dcf282ba9ec9fb39977cded61cd5d94f78c23d1db3cd53/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "bdb0cb3b8be2",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8000/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": null,
            "Image": "registry.gitlab.com/preciselydata/di-suite-saas-platform/encryption-service:467702848.119bb47d",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "./encryption-service"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "b82afe2b1ef11ed6c1dba83dd748ea5e7b4fdedbfdf63743e9fb49fc498e16fe",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8000/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8000"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/b82afe2b1ef1",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "82480ccdc25f752988863e8639c2658fb6e9706095ad1c591e8c313be89c9db0",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "513712b9e4988f4af83c5b9416af52e8c54a77819ac1830933cc57a5b458bcca",
                    "EndpointID": "82480ccdc25f752988863e8639c2658fb6e9706095ad1c591e8c313be89c9db0",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

$ docker inspect vault_c

Output
[
    {
        "Id": "07a7ff272dabfdb8b54c79c1ec1a9b0e4fc3b404b070059dfc95988c032cde72",
        "Created": "2022-02-10T08:12:36.189903478Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "server",
            "-dev"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 492,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-02-10T08:12:36.984765143Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:c82c19c7b24e8ebe12a0e4e0080d5e3c32de0b096836fdd622bc4e7a9fb39012",
        "ResolvConfPath": "/var/lib/docker/containers/07a7ff272dabfdb8b54c79c1ec1a9b0e4fc3b404b070059dfc95988c032cde72/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/07a7ff272dabfdb8b54c79c1ec1a9b0e4fc3b404b070059dfc95988c032cde72/hostname",
        "HostsPath": "/var/lib/docker/containers/07a7ff272dabfdb8b54c79c1ec1a9b0e4fc3b404b070059dfc95988c032cde72/hosts",
        "LogPath": "/var/lib/docker/containers/07a7ff272dabfdb8b54c79c1ec1a9b0e4fc3b404b070059dfc95988c032cde72/07a7ff272dabfdb8b54c79c1ec1a9b0e4fc3b404b070059dfc95988c032cde72-json.log",
        "Name": "/vault_c",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "8200/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8200"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": [
                "IPC_LOCK"
            ],
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/5dfd51aed3927961c18cbdf0f0df3c3a3112369aeaa4b5b28e2e1cee1af946d2-init/diff:/var/lib/docker/overlay2/0373fd6376c54ec8dd7aa3035a728d7c51c996ecb1df79a4187ef081dba08651/diff:/var/lib/docker/overlay2/d22513782685d6f943de65296ca668489dffdcfcfcdf6efc01fdfee323535c00/diff:/var/lib/docker/overlay2/bcdcda170473a91bf6d6383f874065f662c12daf9ecb6c019e0a6de07aa394ea/diff:/var/lib/docker/overlay2/0ea8746053512a2617654c2947d7f84acda3cb0568c8f8cffe6091b284153a45/diff:/var/lib/docker/overlay2/b8cae8759bc54892a504e949745321a44d79324d24bb91fe32438ca855f4c3a3/diff",
                "MergedDir": "/var/lib/docker/overlay2/5dfd51aed3927961c18cbdf0f0df3c3a3112369aeaa4b5b28e2e1cee1af946d2/merged",
                "UpperDir": "/var/lib/docker/overlay2/5dfd51aed3927961c18cbdf0f0df3c3a3112369aeaa4b5b28e2e1cee1af946d2/diff",
                "WorkDir": "/var/lib/docker/overlay2/5dfd51aed3927961c18cbdf0f0df3c3a3112369aeaa4b5b28e2e1cee1af946d2/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "59de0924093060f0fc5d532e59b123314909497a5708567b0aac365a157719f3",
                "Source": "/var/lib/docker/volumes/59de0924093060f0fc5d532e59b123314909497a5708567b0aac365a157719f3/_data",
                "Destination": "/vault/file",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "3356783779d6824953ae4bb37828e18ef10af9c804612ec8a614f27bdb68d05d",
                "Source": "/var/lib/docker/volumes/3356783779d6824953ae4bb37828e18ef10af9c804612ec8a614f27bdb68d05d/_data",
                "Destination": "/vault/logs",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "07a7ff272dab",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8200/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "VAULT_DEV_ROOT_TOKEN_ID=myroot",
                "VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "server",
                "-dev"
            ],
            "Image": "vault",
            "Volumes": {
                "/vault/file": {},
                "/vault/logs": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "0e980757aa68685fb677e26e23c92858b9872dd93b8493191e586d39f0f45b9f",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8200/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8200"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/0e980757aa68",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "7d0fba51d16a7726eda5782e09ad6bbd11d1bbfb2cab218bc0ce1230774c6bc7",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.3",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:03",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "513712b9e4988f4af83c5b9416af52e8c54a77819ac1830933cc57a5b458bcca",
                    "EndpointID": "7d0fba51d16a7726eda5782e09ad6bbd11d1bbfb2cab218bc0ce1230774c6bc7",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:03",
                    "DriverOpts": null
                }
            }
        }
    }
]

I have edited certain names for privacy.

Why does the 8000 port work, and not the 8200 port not?

I doubt that the published port is the issue if vault runs on port 8200/tcp inside the container. Are you sure the container actualy boostraps corect and vaults start serving request?