I am new to docker. I installed docker on ubuntu18.04 and started an nginx container.
I was able to access the nginx home page by typing in the chrome browser on my current ubuntu machine(192.168.1.81)。
But I couldn’t access the nginx container from my browser on another host(192.168.1.30) on my local network。
Basic Information:
> docker --verison
Docker version 24.0.2, build cb74dfc
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
caa3270a86bb nginx:latest "/docker-entrypoint.…" 3 hours ago Up 3 hours 0.0.0.0:8177->80/tcp, :::8177->80/tcp ng
> docker inspect ng
[
{
"Id": "caa3270a86bb033328cc571887e0d77062acc483046eaeea801a1ce31e4cadeb",
"Created": "2025-01-08T02:17:30.445362728Z",
"Path": "/docker-entrypoint.sh",
"Args": [
"nginx",
"-g",
"daemon off;"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 8475,
"ExitCode": 0,
"Error": "",
"StartedAt": "2025-01-08T02:17:32.324519855Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:f876bfc1cc63d905bb9c8ebc5adc98375bb8e22920959719d1a96e8f594868fa",
"ResolvConfPath": "/data/docker/containers/caa3270a86bb033328cc571887e0d77062acc483046eaeea801a1ce31e4cadeb/resolv.conf",
"HostnamePath": "/data/docker/containers/caa3270a86bb033328cc571887e0d77062acc483046eaeea801a1ce31e4cadeb/hostname",
"HostsPath": "/data/docker/containers/caa3270a86bb033328cc571887e0d77062acc483046eaeea801a1ce31e4cadeb/hosts",
"LogPath": "/data/docker/containers/caa3270a86bb033328cc571887e0d77062acc483046eaeea801a1ce31e4cadeb/caa3270a86bb033328cc571887e0d77062acc483046eaeea801a1ce31e4cadeb-json.log",
"Name": "/ng",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "8177"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
37,
169
],
"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",
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"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": "/data/docker/overlay2/0f12ba9abf6bc34c939307aedd3bb32bbc8a3c15abe6d69af5647f6a79089ac2-init/diff:/data/docker/overlay2/4999cb990edee1da3512c658899a254c47921a582859d766fbb9ede3b711ca2a/diff:/data/docker/overlay2/23223ac319f9ff7d43dfc06b5c55195dc1724d3ada4ebb43c60ffa98edf5450f/diff:/data/docker/overlay2/1fe2da5330609ee536019f193247dfa1cc342eb58d74f0b4e9ef3ebad3b670d3/diff:/data/docker/overlay2/78c9edff24fc98e873143ea73b41fd5467daf3520639edeb4370df3c10a63b11/diff:/data/docker/overlay2/4e85f01f91d8e763dcf69c61ac6678516e97a3bdbd3fac8c02464a5e8f82b591/diff:/data/docker/overlay2/a00f6f73527df7dfd514fe7c1a6c87c4c695b95a135aafe82df2679d0d8b33d9/diff:/data/docker/overlay2/6ca112f40bde167b1bb2f807ee01121a8fa66d4215cfacac38ba4bf3ecda9abb/diff",
"MergedDir": "/data/docker/overlay2/0f12ba9abf6bc34c939307aedd3bb32bbc8a3c15abe6d69af5647f6a79089ac2/merged",
"UpperDir": "/data/docker/overlay2/0f12ba9abf6bc34c939307aedd3bb32bbc8a3c15abe6d69af5647f6a79089ac2/diff",
"WorkDir": "/data/docker/overlay2/0f12ba9abf6bc34c939307aedd3bb32bbc8a3c15abe6d69af5647f6a79089ac2/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "caa3270a86bb",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.27.3",
"NJS_VERSION=0.8.7",
"NJS_RELEASE=1~bookworm",
"PKG_RELEASE=1~bookworm",
"DYNPKG_RELEASE=1~bookworm"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"Image": "nginx:latest",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
},
"StopSignal": "SIGQUIT"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "e52b8d09a01cfe19891f8cda830268d5fbb9f4ee9912b81044ff94a91325474f",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8177"
},
{
"HostIp": "::",
"HostPort": "8177"
}
]
},
"SandboxKey": "/var/run/docker/netns/e52b8d09a01c",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "5b1095bd18aa0cff5109edcd7a29af6c0a6c46e5ad0617f60f21c0ec8462ddc8",
"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": "5eea08bc357fd33559aca9dc60937ad9f3a75b30f1a343071ccfe84a4da49373",
"EndpointID": "5b1095bd18aa0cff5109edcd7a29af6c0a6c46e5ad0617f60f21c0ec8462ddc8",
"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
}
}
}
}
]
> sudo ufw status
Status: Inactive