Related
I stopped my docker container.
and i restart the service in linux (service docker restart)
after that my container is missing.
I typed docker ps -a but I can't find my splunk container.
I can find container directory and volume folder also.
also I have every folder in inspection result.
but I can't see when I type docker ps -a
how can I restore it ?
this is my docker inspect result, when container is exist.
[
{
"Id": "9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039",
"Created": "2018-10-02T04:05:28.013507313Z",
"Path": "/sbin/entrypoint.sh",
"Args": [
"start-service"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 11513,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-09-22T05:22:09.939497539Z",
"FinishedAt": "2020-09-22T05:20:05.99542747Z"
},
"Image": "sha256:507021d7e77f9bdd337aeb47729a806162579f36e5d73b14f2a508e545adae72",
"ResolvConfPath": "/storage/docker/containers/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039/resolv.conf",
"HostnamePath": "/storage/docker/containers/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039/hostname",
"HostsPath": "/storage/docker/containers/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039/hosts",
"LogPath": "/storage/docker/containers/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039/9e12bb7b2f8a926c0b7852aa9f1bf957363f327d6de53778059bf0fc05711039-json.log",
"Name": "/splunk",
"RestartCount": 0,
"Driver": "overlay",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"8000/tcp": [
{
"HostIp": "",
"HostPort": "8000"
}
],
"8089/tcp": [
{
"HostIp": "",
"HostPort": "8089"
}
]
},
"RestartPolicy": {
"Name": "unless-stopped",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"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": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": {
"LowerDir": "/storage/docker/overlay/25444b7c23c5d0bf0a6d4d1563a587831b7c329e6623ee720e609a0a16787ef5/root",
"MergedDir": "/storage/docker/overlay/53d6023089444b76af280ef1220a2851c1b5045167c471f5f60f9faa0389ccd3/merged",
"UpperDir": "/storage/docker/overlay/53d6023089444b76af280ef1220a2851c1b5045167c471f5f60f9faa0389ccd3/upper",
"WorkDir": "/storage/docker/overlay/53d6023089444b76af280ef1220a2851c1b5045167c471f5f60f9faa0389ccd3/work"
},
"Name": "overlay"
},
"Mounts": [
{
"Type": "volume",
"Name": "cb9d0886db87a17304310bfa5a242972bf9c76464eb0c85c24902c7764443714",
"Source": "/storage/docker/volumes/cb9d0886db87a17304310bfa5a242972bf9c76464eb0c85c24902c7764443714/_data",
"Destination": "/opt/splunk/etc",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Type": "volume",
"Name": "5d637a70101b4d6a80261abfeac9534b8b77bde4669c6225dedf3a9bcfb4434a",
"Source": "/storage/docker/volumes/5d637a70101b4d6a80261abfeac9534b8b77bde4669c6225dedf3a9bcfb4434a/_data",
"Destination": "/opt/splunk/var",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "9e12bb7b2f8a",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"1514/tcp": {},
"8000/tcp": {},
"8088/tcp": {},
"8089/tcp": {},
"8191/tcp": {},
"9997/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"SPLUNK_START_ARGS=--accept-license",
"SPLUNK_USER=root",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"SPLUNK_PRODUCT=splunk",
"SPLUNK_VERSION=7.0.0",
"SPLUNK_BUILD=c8a78efdd40f",
"SPLUNK_FILENAME=splunk-7.0.0-c8a78efdd40f-Linux-x86_64.tgz",
"SPLUNK_HOME=/opt/splunk",
"SPLUNK_APPS=/opt/splunk/etc/apps",
"SPLUNK_GROUP=splunk",
"SPLUNK_BACKUP_DEFAULT_ETC=/var/opt/splunk",
"LANG=en_US.utf8",
"JAVA_HOME=/opt/jdk/jdk1.8.0_152/"
],
"Cmd": [
"start-service"
],
"ArgsEscaped": true,
"Image": "klustree/splunk:7.0.0",
"Volumes": {
"/opt/splunk/etc": {},
"/opt/splunk/var": {}
},
"WorkingDir": "/opt/splunk",
"Entrypoint": [
"/sbin/entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "57cf9a7d9ec5d31e685fd5ea9232a3126fab1a90406449cc4d48b43a2f7c4f57",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"1514/tcp": null,
"8000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8000"
}
],
"8088/tcp": null,
"8089/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8089"
}
],
"8191/tcp": null,
"9997/tcp": null
},
"SandboxKey": "/var/run/docker/netns/57cf9a7d9ec5",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "b4d39d4b6615127cd6aaeda1e0e14e73d910fadf9b596d5b81698d3fc1c53945",
"Gateway": "172.17.1.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.1.4",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:01:04",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "c563f5e5d0e2e4bd6d35f5802395f77874679e40a522dabaee59b93d3747619c",
"EndpointID": "b4d39d4b6615127cd6aaeda1e0e14e73d910fadf9b596d5b81698d3fc1c53945",
"Gateway": "172.17.1.1",
"IPAddress": "172.17.1.4",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:01:04",
"DriverOpts": null
}
}
}
}
]
please help...
This is the default behavior of the docker service, in the docs we learn:
By default, when the Docker daemon terminates, it shuts down running containers. Starting with Docker Engine 1.12, you can configure the daemon so that containers remain running if the daemon becomes unavailable. This functionality is called live restore. The live restore option helps reduce container downtime due to daemon crashes, planned outages, or upgrades.
Here you can learn how to keep your containers alive when occurring a service timeout.
And here you can configure for your containers still alive when the docker service is restarted.
Although live-restore and the restart policy might seem similar they have different purposes:
Restart policies are different from the --live-restore flag of the dockerd command. Using --live-restore allows you to keep your containers running during a Docker upgrade, though networking and user input are interrupted.
I have a docker deployment with 3 services (using docker-compose) and the following port mappings:
nginx (90 → 80)
node (3000 → 3000)
python (8001 → 8000)
Python is a demo aiohttp app (aiohttp-based) served on port 8000
The node app is a simple ssr frontend served on port 3000
Nginx acts as a reverse proxy and has this clause to route traffic to the python app:
location /api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://python:8000;
}
And this one to route to the node app:
location / {
proxy_pass http://node:3000;
include /etc/nginx/node_params;
}
The problem is that the none of the other two containers can connect to the python container:
$ docker-compose exec nginx curl 'http://python:8000/api/'
curl: (7) Failed to connect to python port 8000: Connection refused
Same by using the IP directly:
$ docker-compose exec node curl 'http://172.18.0.5:8000/api/'
curl: (7) Failed to connect to 172.18.0.5 port 8000: Connection refused
Checking open ports also fails:
$ docker-compose exec nginx nc -vz python 8000
$ <no response>
Only the python container can connect to itself:
$ docker-compose exec python curl 'http://python:8000/api/'
Response ok
$ docker-compose exec python nc -vz python 8000
python (172.18.0.5:8000) open
The other service (node) can be accessed normally. Pinging the container also works.
The only way it can be accessed is from outside the docker network by the mapped port (8001), i.e.:
$ curl http://localhost:8001/api/
Response ok
It works with any IP and even from another hosts over the internet:
$ curl http://my-app.mydomain.com:8001/api/
Response ok
I am also not able to reproduce this problem because the same project run on my local machine works completely fine. The only difference is that where I'm trying to run it it's using docker 17 (Docker version 17.06.0-ce, build 02c1d87) whereas my local machine runs docker 18 (Docker version 18.09.5, build e8ff056). Also the server is running fedora 24 vs fedora 29 on my machine.
What am I doing wrong?
This is my docker-compose.yml file
version: '3.7'
services:
python:
build: api
ports:
- 8001:8000
networks:
default:
aliases:
- python
restart: always
volumes:
- cdn:/app/cdn
frontend:
build:
context: nuxt
ports:
- 3000:3000
networks:
default:
aliases:
- node
restart: always
nginx:
build:
context: nginx
ports:
- 90:80
restart: always
volumes:
- cdn:/app/cdn
volumes:
cdn:
Edit:
$ docker inspect project_python_1
[
{
"Id": "98f3624ea0866665204167d9975b050977836b843c8294639e245897c0c8e44e",
"Created": "2019-05-07T14:03:17.714587695Z",
"Path": "/bin/sh",
"Args": [
"-c",
"cd src && python -m api"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 5268,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-05-07T14:03:18.860468562Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:6b9059304a2e0f5316204acaf37423a557dc8d14dbc3bc72e169430ff38df73c",
"ResolvConfPath": "/var/lib/docker/containers/98f3624ea0866665204167d9975b050977836b843c8294639e245897c0c8e44e/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/98f3624ea0866665204167d9975b050977836b843c8294639e245897c0c8e44e/hostname",
"HostsPath": "/var/lib/docker/containers/98f3624ea0866665204167d9975b050977836b843c8294639e245897c0c8e44e/hosts",
"LogPath": "/var/lib/docker/containers/98f3624ea0866665204167d9975b050977836b843c8294639e245897c0c8e44e/98f3624ea0866665204167d9975b050977836b843c8294639e245897c0c8e44e-json.log",
"Name": "/project_python_1",
"RestartCount": 0,
"Driver": "overlay2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"cdn:/app/cdn:rw"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "project_default",
"PortBindings": {
"8000/tcp": [
{
"HostIp": "",
"HostPort": "8001"
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"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": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/013c07caf2f6fd59e99a7ec626355e8820d7fe6c0d2f83d5ed0fd2a0c2688ea9-init/diff:/var/lib/docker/overlay2/b1986769f12e6919ad34bb2184a4822a18d01c402b187d8caf7d1088f6020da1/diff:/var/lib/docker/overlay2/919b177579f26bde763973564af0a3762db5fb9d801b9804f5038fb9c60e4250/diff:/var/lib/docker/overlay2/22389c009280043fe76e9e2631e59aa3d6ee35a827613114e39db5f4d29783b7/diff:/var/lib/docker/overlay2/098414feeb05448f0b70dad272c9c81976171d7626e902c9325c5a454b666e59/diff:/var/lib/docker/overlay2/91cf4d7cef0ffb067991afc5b99ebb7ffee6fb02ce6e258304b23202a49d71a9/diff:/var/lib/docker/overlay2/7d13e7a43ebd06c9babf901e9630ff663c5036886df08038ccbda5f730e7c3a5/diff:/var/lib/docker/overlay2/f8db754b7d72fc8cd0fcfdd758a9491ffc1029e7cac0f5f884d8f0ca26aee253/diff:/var/lib/docker/overlay2/b0cb3c0f4b0d1eba56f353767142bdccbe08b9d15cddf0b52f2173cb771f850a/diff:/var/lib/docker/overlay2/228b0ee3f88b6b9ab9a436612f416acb02dd7196fb3870ba632c973f560ca75e/diff:/var/lib/docker/overlay2/ee2d7a211a67bc164f787443de343de51efc89e00592a7516acd26f1a02bf520/diff:/var/lib/docker/overlay2/40a529d74eb8c72cbc3e57db301678996e229b4b4de31a5b3f5642c44018c499/diff:/var/lib/docker/overlay2/95534c69b64738866cd6a87a73dda2f049a28745bea72dbd54c6fb6f662202e3/diff:/var/lib/docker/overlay2/69ce7a7e7ad79423e0abab05a3b4270a4a309686ab4410759e05248286799cb6/diff:/var/lib/docker/overlay2/6525630fd688dbae59699c3cf1246cc5a202e4a4265b6cc17e238cd90867ad54/diff:/var/lib/docker/overlay2/66f8ad83ba1c1bd4c719ebfc004b85f4b6aef9bb15fba5f5ea9b5a58f7eb198c/diff:/var/lib/docker/overlay2/a1ca64fad83b74d88984bd7378905308ed5e9bc142f9fb50392b4414b6076eb2/diff",
"MergedDir": "/var/lib/docker/overlay2/013c07caf2f6fd59e99a7ec626355e8820d7fe6c0d2f83d5ed0fd2a0c2688ea9/merged",
"UpperDir": "/var/lib/docker/overlay2/013c07caf2f6fd59e99a7ec626355e8820d7fe6c0d2f83d5ed0fd2a0c2688ea9/diff",
"WorkDir": "/var/lib/docker/overlay2/013c07caf2f6fd59e99a7ec626355e8820d7fe6c0d2f83d5ed0fd2a0c2688ea9/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "volume",
"Name": "cdn",
"Source": "/var/lib/docker/volumes/cdn/_data",
"Destination": "/app/cdn",
"Driver": "local",
"Mode": "rw",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "98f3624ea086",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8000/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"DEBUG=1",
"PATH=scripts:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"GPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D",
"PYTHON_VERSION=3.7.3",
"PYTHON_PIP_VERSION=19.1"
],
"Cmd": [
"/bin/sh",
"-c",
"cd src && python -m api"
],
"ArgsEscaped": true,
"Image": "project_python",
"Volumes": {
"/app/cdn": {}
},
"WorkingDir": "/app",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "0f0fe6053d92416fd77f6efba7e8282f385c447b8a8d40aa866554ee282896d7",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "project",
"com.docker.compose.service": "python",
"com.docker.compose.version": "1.24.0"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "397d60b1dbe4733910c9ae2c0dabc1bdb3046d784b25f8fb4f72c28f6d458ff2",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8001"
}
]
},
"SandboxKey": "/var/run/docker/netns/397d60b1dbe4",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"project_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"98f3624ea086",
"api",
"python"
],
"NetworkID": "4145a30ce48519a895707d607265635012341f73db63b9fedf6e86d68fad6641",
"EndpointID": "4b4bafed80cb88693e2c3f3c1b0268f95afefc3eb7e713ce88d20392d36fa85c",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.5",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:05",
"DriverOpts": null
}
}
}
}
]
Okay, so I found the culprit, the problem was that the machine I was deploying to had a port mapping set up via firewalld, 8000→80, on the main interface eth0, and docker was using that when trying to access the container. I.e. When the nginx container tried to connect to the python container in port 8000, it was actually using 80 as upstream and thus failing. A workaround is to either remove the port mapping or using an unmapped port. I have no idea why would docker apply the same rules of the system's firewalld in its internal networks.
This is the output of firewall-cmd --list-all
FedoraServer (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client
ports: 22/tcp 9090/tcp 90/tcp 8001/tcp 3000/tcp
protocols:
masquerade: no
forward-ports: port=8000:proto=tcp:toport=80:toaddr=
source-ports:
icmp-blocks:
rich rules:
And this is the output of docker network inspect project_default:
[
{
"Name": "project_default",
"Id": "4145a30ce48519a895707d607265635012341f73db63b9fedf6e86d68fad6641",
"Created": "2019-05-07T09:03:17.425575867-05:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"02f1f96b74eb292eeff1eb623e725a41c2a14aa0fc40f727ba78e0a620812254": {
"Name": "project_nginx_1",
"EndpointID": "68c3c7fb40d2e56d6601136a123fc8b7834c0503e3da99be56fac40750247a37",
"MacAddress": ...,
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
},
"1e93a55f0d329f4cc8beb681c3e17c6aec1ded73de5dca2fc1eaf49dae788516": {
"Name": "project_mongo_1",
"EndpointID": "3a0a6ae0dfdc922b5fa6032c492376643e4b61415743af7afae2de33576f3acf",
"MacAddress": ...,
"IPv4Address": "172.18.0.4/16",
"IPv6Address": ""
},
"39ac596559da13506abcce9941a06441f42bd1c2d153d118bd13ff9a57f8c538": {
"Name": "project_node_1",
"EndpointID": "6753668d5fb20d908660b48bb757f9b6755c5f4f0bae69c7e02f5431c8f0e575",
"MacAddress": ...,
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
},
"98f3624ea0866665204167d9975b050977836b843c8294639e245897c0c8e44e": {
"Name": "project_python_1",
"EndpointID": "4b4bafed80cb88693e2c3f3c1b0268f95afefc3eb7e713ce88d20392d36fa85c",
"MacAddress": ...,
"IPv4Address": "172.18.0.5/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "project",
"com.docker.compose.version": "1.24.0"
}
}
]
This is the stripped output of docker ps:
PORTS NAMES
0.0.0.0:8001->8000/tcp project_python_1
27017/tcp, 28017/tcp project_mongo_1
0.0.0.0:90->80/tcp project_nginx_1
0.0.0.0:3000->3000/tcp project_node_1
I'm runnig RabbitMQ in docker
>docker run -d --hostname my-rabbit --name some-rabbit --rm --network my-bridge rabbitmq
My container name is some-rabbit and my hostname is my-rabbit
The container is connected to my-bridge network
My app is also connected to my-bridge network
docker network inspect my-bridge produces:
[
{
"Name": "my-bridge",
"Id": "c996f5318b2b3ff907b6680e41c4551f184f2c43b0df43fd6916fa8d1707e427",
"Created": "2018-12-26T19:40:46.6982856Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.21.0.0/16",
"Gateway": "172.21.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"98d81ba991febbc9dc0775effc79a2b083f62fe563aad3ce146e56bab5b09f4c": {
"Name": "some-rabbit",
"EndpointID": "acb3da3e91d655a3ed245fa3938edd681318129e514b83db07e1b4efd4f2bfc2",
"MacAddress": "02:42:ac:15:00:02",
"IPv4Address": "172.21.0.2/16",
"IPv6Address": ""
},
"9fdf456e352e932b13530223f736028f357e63ead5ace042a13200f6d5744d62": {
"Name": "dockercompose8897046891659778892_publisher_1",
"EndpointID": "f45ba7f9c7832d3514d22ddf29bc19f1e74529cb371b335542c9eb54469fe7a4",
"MacAddress": "02:42:ac:15:00:04",
"IPv4Address": "172.21.0.4/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
docker inspect some-rabbit produces:
...
"Config": {
"Hostname": "my-rabbit",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"25672/tcp": {},
"4369/tcp": {},
"5671/tcp": {},
"5672/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/lib/rabbitmq/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.10",
"RABBITMQ_LOGS=-",
"RABBITMQ_SASL_LOGS=-",
"RABBITMQ_GPG_KEY=0A9AF2115F4687BD29803A206B73A36E6026DFCA",
"RABBITMQ_VERSION=3.7.8",
"RABBITMQ_GITHUB_TAG=v3.7.8",
"RABBITMQ_DEBIAN_VERSION=3.7.8-1",
"LANG=C.UTF-8",
"HOME=/var/lib/rabbitmq"
],
"Cmd": [
"rabbitmq-server"
],
"ArgsEscaped": true,
"Image": "rabbitmq",
"Volumes": {
"/var/lib/rabbitmq": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "bac2e155323c1ec94e145a37f45f8bc0d32e28a2b363cb1c9f3d4ed922a91a56",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"25672/tcp": null,
"4369/tcp": null,
"5671/tcp": null,
"5672/tcp": null
},
"SandboxKey": "/var/run/docker/netns/bac2e155323c",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"my-bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"98d81ba991fe"
],
"NetworkID": "c996f5318b2b3ff907b6680e41c4551f184f2c43b0df43fd6916fa8d1707e427",
"EndpointID": "acb3da3e91d655a3ed245fa3938edd681318129e514b83db07e1b4efd4f2bfc2",
"Gateway": "172.21.0.1",
"IPAddress": "172.21.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:15:00:02",
"DriverOpts": null
}
}
}
}
]
Concluding:
Both rabbitmq and my app are running in the same network
RabbitMQ has a custom hostname my-rabbit which can be observed when inspecting the container: "Hostname": "my-rabbit"
However when my app is trying to reach RabbitMQ at address my-rabbit, connection fails. Only if I use the container name as the address (some-rabbit) it works.
Is my understanding of --hostname wrong or am I using it wrong? When is it useful to use custom --hostname?
Hostname is only visible to the application inside that same container. Docker's embedded DNS will not resolve container hostnames. What you can resolve with docker's DNS are:
container name
container id
network alias for a container (including the service name in a compose file)
http://localhost:4200 doesn't work on host
But server is running inside container
docker exec 697bf01cf064 curl http://0.0.0.0:4200/
<!doctype html>
...
This command
docker-machine ip default
returns
192.168.99.100
http://192.168.99.100:4200 doesn't work too
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
697bf01cf064 wepoll_wepoll-ui-webpack-docker "npm start --host=..." 19 minutes ago Up 19 minutes 0.0.0.0:4200->4200/tcp, 0.0.0.0:49152->49152/tcp wepoll-ui-webpack-docker
EXPOSE 4200 49152 in Dockerfile
networks:
dev-network:
driver: bridge
Network driver - bridge
How to access container server from host? Firewall disabled.
docker inpect 68e5e3524906
[
{
"Id": "68e5e3524906d621f3abc3cdfcb58e740290bb12a2082e44c14e180fecabb111",
"Created": "2017-02-01T16:56:34.52365653Z",
"Path": "npm",
"Args": [
"start",
"--host=0.0.0.0"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 4483,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-02-01T16:56:34.833112923Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:a8aa417d60182b300836ce3f556bf90ae5b71fcf1ef9f76f4ef0d41b461934d1",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/68e5e3524906d621f3abc3cdfcb58e740290bb12a2082e44c14e180fecabb111/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/68e5e3524906d621f3abc3cdfcb58e740290bb12a2082e44c14e180fecabb111/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/68e5e3524906d621f3abc3cdfcb58e740290bb12a2082e44c14e180fecabb111/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/68e5e3524906d621f3abc3cdfcb58e740290bb12a2082e44c14e180fecabb111/68e5e3524906d621f3abc3cdfcb58e740290bb12a2082e44c14e180fecabb111-json.log",
"Name": "/wepoll-ui-webpack-docker",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "wepoll_dev-network",
"PortBindings": {
"4200/tcp": [
{
"HostIp": "",
"HostPort": "4200"
}
],
"49152/tcp": [
{
"HostIp": "",
"HostPort": "49152"
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"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": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [],
"Config": {
"Hostname": "68e5e3524906",
"Domainname": "",
"User": "app",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"4200/tcp": {},
"49152/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NPM_CONFIG_LOGLEVEL=info",
"NODE_VERSION=6.6.0",
"HOME=/home/app",
"APP_NAME=wepoll-ui-webpack-docker"
],
"Cmd": [
"npm",
"start",
"--host=0.0.0.0"
],
"Image": "wepoll_wepoll-ui-webpack-docker",
"Volumes": null,
"WorkingDir": "/home/app/wepoll-ui-webpack-docker",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "b1e41fe8d248646d782943b8997d539b910c984b9a862335c080458afd44bd1e",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "wepoll",
"com.docker.compose.service": "wepoll-ui-webpack-docker",
"com.docker.compose.version": "1.10.0"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "7b8e3391317a645ec316183e6d1f8a4865418185598d8088d47f808987006bbf",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"4200/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "4200"
}
],
"49152/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "49152"
}
]
},
"SandboxKey": "/var/run/docker/netns/7b8e3391317a",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"wepoll_dev-network": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"wepoll-ui-webpack-docker",
"68e5e3524906"
],
"NetworkID": "4c5594b896a4050f60133f44e494021aaf5606488d22af963561febb0ee6049b",
"EndpointID": "603c3628945054bd62a9deaa574a782241b544502bb525333f2865da3f705d9a",
"Gateway": "172.19.0.1",
"IPAddress": "172.19.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:13:00:02"
}
}
}
}
]
Debugging:
The fact that you are unable to browse app at ${host_ip}:4200 means that it could be possible that the port is not exposed properly.
But the output for docker ps under the PORTS section has...
0.0.0.0:4200->4200/tcp
...which means that port has been exposed correctly.
Let's check if the port over the container's IP is reachable (to remove any suspicions on firewalls)
The output for docker inspect ${container_id} shows that your container IP is 172.19.0.2 (and also proves that the port bindings are correct). But http://172.19.0.2:4200 is also not reachable.
But you already mentioned that curl 0.0.0.0 inside machine works, but 0.0.0.0, in this context, means "all IP addresses on the local machine" (in fact probably, "all IPv4 addresses on the local machine"), which also includes 127.0.0.1 aka localhost, which doesn't prove that your app is listening on all interfaces.
Now you say that you started the app with --host=0.0.0.0, but I think you can still override it inside the app code.
So, the best case scenario is to inspect how the app server is started.
I am facing a problem. Please let me know if I am doing something wrong.
I have created a local docker repository (dev, file system) and tried to push some local images on to the same.
The local images were saved on the repository and the GET requests showed the JSON contents.
but then, I wanted to delete these images from the repository and for that I used the HTTP DELETE requests, deleting the "library" and the images from the repository.
The problem is that the space eaten up by the images that were pushed to the repo has not been freed up.
I have deleted the container running the repository and also the repository image itself, but the space is still not freed up.
Strange is that the same is not visible in any of the system directories even id I do a du -hs /* in /.
Contents of the repo query attached.
[{
"Args": [
"-c",
"exec docker-registry"
],
"Config": {
"AttachStderr": true,
"AttachStdin": false,
"AttachStdout": true,
"Cmd": [
"/bin/sh",
"-c",
"exec docker-registry"
],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": null,
"Env": [
"HOME=/",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DOCKER_REGISTRY_CONFIG=/docker-registry/config/config_sample.yml",
"SETTINGS_FLAVOR=dev"
],
"ExposedPorts": {
"5000/tcp": {}
},
"Hostname": "db6454154305",
"Image": "registry",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": null,
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": {
"/docker/registry": {}
},
"WorkingDir": ""
},
"Created": "2014-08-25T14:12:03.711327013Z",
"Driver": "aufs",
"ExecDriver": "native-0.2",
"HostConfig": {
"Binds": null,
"CapAdd": null,
"CapDrop": null,
"ContainerIDFile": "",
"Devices": [],
"Dns": null,
"DnsSearch": null,
"Links": null,
"LxcConf": [],
"NetworkMode": "bridge",
"PortBindings": {
"5000/tcp": [
{
"HostIp": "",
"HostPort": "5000"
}
]
},
"Privileged": false,
"PublishAllPorts": false,
"RestartPolicy": {
"MaximumRetryCount": 0,
"Name": ""
},
"VolumesFrom": null
},
"HostnamePath": "/var/lib/docker/containers/db6454154305015c410c068e4d641d535fab1434edf91238ebd4bd5933fd159b/hostname",
"HostsPath": "/var/lib/docker/containers/db6454154305015c410c068e4d641d535fab1434edf91238ebd4bd5933fd159b/hosts",
"Id": "db6454154305015c410c068e4d641d535fab1434edf91238ebd4bd5933fd159b",
"Image": "cd3581c06bdcb2cfd877f79102b8e48a90e7fd723b4b4c6ee34d1f1dd6f64303",
"MountLabel": "",
"Name": "/dreamy_pike",
"NetworkSettings": {
"Bridge": "docker0",
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"PortMapping": null,
"Ports": {
"5000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "5000"
}
]
}
},
"Path": "/bin/sh",
"ProcessLabel": "",
"ResolvConfPath": "/var/lib/docker/containers/db6454154305015c410c068e4d641d535fab1434edf91238ebd4bd5933fd159b/resolv.conf",
"State": {
"ExitCode": 0,
"FinishedAt": "2014-08-26T06:21:16.792306236Z",
"Paused": false,
"Pid": 5645,
"Restarting": false,
"Running": true,
"StartedAt": "2014-08-26T08:38:57.051361284Z"
},
"Volumes": {
"/docker/registry": "/var/lib/docker/vfs/dir/ae9ac9a2649acce729fde429586a7d1b4b7fe7ec834c12bea4b8b5519e2740a8"
},
"VolumesRW": {
"/docker/registry": true
}
}]
Posible answer:
Deleting images from a private docker registry
Cannot try if this works as I deleted my virtual machine.
But thanks anyway for the help Konrad Kleine
https://stackoverflow.com/users/835098/konrad-kleine