Related
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)
I started a rethinkDB docker container using the command
docker pull rethinkdb:2.3
docker run --rm --name rethinkdb -v /srv/rethinkdb:/data --net host rethinkdb:2.3 rethinkdb --bind all --cache-size 8192 --no-update-check
Now the container started successfully. I did docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f288961ef376 rethinkdb:2.3 "rethinkdb --bind ..." 9 minutes ago Up 9 minutes rethinkdb
1f71722698ae sorccu/adb:latest "/sbin/tini -- adb..." 14 minutes ago Up 14 minutes adbd
Now I want to find out the IP address of this container. So I did
docker inspect --format '{{ .NetworkSettings.IPAddress }}' f288961ef376
It's returning me nothing. I couldn't find IP address for this container.
I checked if the rethinkDB configuration page is up or not by going to http://localhost:8080 and I see it's up and running.
Why doesn't this container have any IP address?
Output of docker inspect is as follows
[
{
"Id": "f288961ef376531c97d2264cb8ef3c6077a6a75107905d6a47734303adfcb117",
"Created": "2017-05-05T11:13:45.382460184Z",
"Path": "rethinkdb",
"Args": [
"--bind",
"all",
"--cache-size",
"8192",
"--no-update-check"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 8157,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-05-05T11:13:45.774035358Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:c5ed876750b40cde4725ea9eb9d8503f4d1419a2f23ac2ef8e4cc1d535e2c3a2",
"ResolvConfPath": "/var/lib/docker/containers/f288961ef376531c97d2264cb8ef3c6077a6a75107905d6a47734303adfcb117/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/f288961ef376531c97d2264cb8ef3c6077a6a75107905d6a47734303adfcb117/hostname",
"HostsPath": "/var/lib/docker/containers/f288961ef376531c97d2264cb8ef3c6077a6a75107905d6a47734303adfcb117/hosts",
"LogPath": "/var/lib/docker/containers/f288961ef376531c97d2264cb8ef3c6077a6a75107905d6a47734303adfcb117/f288961ef376531c97d2264cb8ef3c6077a6a75107905d6a47734303adfcb117-json.log",
"Name": "/rethinkdb",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/srv/rethinkdb:/data"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "host",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": true,
"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": null,
"Name": "aufs"
},
"Mounts": [
{
"Type": "bind",
"Source": "/srv/rethinkdb",
"Destination": "/data",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "dev-machine",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"28015/tcp": {},
"29015/tcp": {},
"8080/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"RETHINKDB_PACKAGE_VERSION=2.3.5~0jessie"
],
"Cmd": [
"rethinkdb",
"--bind",
"all",
"--cache-size",
"8192",
"--no-update-check"
],
"Image": "rethinkdb:2.3",
"Volumes": {
"/data": {}
},
"WorkingDir": "/data",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "bd17bf8e1663ff18f6674a1a3a1665c4e1bf65283d358ffc97dc238ef4a79088",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/default",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"host": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "30b6150968580d33aae0e45f7d850b9e67ae2aa29e1bb837ca4fa74f2b0d4d42",
"EndpointID": "05e93ec514ee6694e57d344f3e4362252104347c3cc48c607708d125715ed6ec",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": ""
}
}
}
}
]
You are starting your container with the --net host option which means your container will run on your host network. Check here for more info. So your container will be accessible on the IP of your host.
A very basic example:
$ docker run --net=host -d jenkins
This will run jenkins on your real host network. So when you open the firewall (jenkins runs on 8080) you will access your container immediatly.
So I open the firewall:
$ sudo iptables -I INPUT 5 -p tcp -m tcp --dport 8080 -j ACCEPT
I check the real IP of my eth0 (host network) with ifconfig. (I'm doing this on a VM). It is inet 192.168.140.7. I go in my browser to 192.168.140.7:8080 and I see the jenkins. So your container has no own IP. It's running on your host network and host IP.
If you leave the --net host option, the container will be created in the default docker bridge network with range "172.17.0.0/16". Now your container will get an IP from in the range of that network. To access the container from the outside you have to map your ports on your host network (see the more info). You can do this with the -p option.
So for the jenkins example:
$ docker run -d -p 8888:8080 jenkins
When I perform a docker inspect I see:
"IPAddress": "172.17.0.4",
So my container is running in the bridge network on 172.17.0.4:8080.
Now with the -p option I'm mapping the port 8080 of my bridge network on 8888 of my host network: so host-IP:8888. Now it's accessible from the outside.
Your container ip the the same as the host. host basically says that your container uses the same network interface as the host. It is fast since there's no bridging but limited; You have to make sure that your containers do not listen to the same port to avoid conflicts.
It's better to stick with the default bridge network and specify the port that you want exposed to the host. For instance:
docker run --rm --name rethinkdb -v /srv/rethinkdb:/data -p 8080:8080 \
rethinkdb:2.3 rethinkdb --bind all --cache-size 8192 --no-update-check
btw, --net has been renamed --network in later versions of Docker.
I am having two docker containers in IBM Bluemix. One is MQTT and other php-python.
The PHP application executes a python script that should connect to the MQTT docker container and subscribe to a topic.
However, the php-python docker fails to connect. It also fails to ping to the MQTT docker container.
The MQTT container is working perfect as I am able to connect to it from my local machine.
I have tried linking the two containers using the following command:
cf ic run -p 443 -p 80 --name connector --link moscacontainer:source
registry.ng.bluemix.net/fortspace/php-mqtt
I have exposed the ports 1883 and 80 for the MQTT container.
I have used the following link as reference:
https://github.com/dceejay/nrdock/blob/master/README.md#linking-containers
Can someone guide on this?
EDIT: The output for cf ic inspect
[
{
"BluemixApp": null,
"BluemixServices": null,
"Config": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [],
"Dns": "",
"Env": [
"logging_password=",
"space_id=f874124c-cea6-460e-9bf2-b633eeeefcdf",
"logstash_target=logmet.opvis.bluemix.net:9091",
"metrics_target=logmet.opvis.bluemix.net:9095"
],
"Hostname": "instance-0018c601",
"Image": "registry.ng.bluemix.net/fortspace/php-mqtt:latest",
"ImageArchitecture": "amd64",
"Labels": {},
"Memory": 256,
"MemorySwap": "",
"OpenStdin": true,
"PortSpecs": "",
"StdinOnce": false,
"Tty": true,
"User": "",
"VCPU": 1,
"VolumesFrom": "",
"WorkingDir": ""
},
"ContainerState": "Running",
"Created": "2017-01-11T06:21:38.000000000Z",
"Group": {},
"HostConfig": {
"Binds": [],
"CapAdd": [],
"CapDrop": [],
"ContainerIDFile": "",
"Links": [
"moscacontainer:source"
],
"LogConfig": {
"Config": {},
"Type": "json-file"
},
"LxcConf": [],
"PortBindings": {
"443/tcp": [
{
"HostPort": "443"
}
],
"80/tcp": [
{
"HostPort": "80"
}
]
},
"Privileged": false,
"PublishAllPorts": false
},
"HostId": "46f8e5e8739f205e67ec852485095e953f079ff5c8f95b9e7c16f331",
"Human_id": "connector",
"Id": "4920a824-66bf-49bd-be71-549d0adeeffc",
"Image": "sha256:080893a1e47927b2fdf3f24a8b0b803fab035c236551e32df9527654c8af698c",
"Mounts": [],
"Name": "connector",
"NetworkSettings": {
"Bridge": "",
"Gateway": "",
"IPAddress": "172.29.0.53",
"IPPrefixLen": 0,
"MacAddress": "fa:16:3e:3a:2e:04",
"Networks": {
"default": {
"Aliases": null,
"EndpointID": "4920a824-66bf-49bd-be71-549d0adeeffc",
"Gateway": "172.29.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAMConfig": null,
"IPAddress": "172.29.0.53",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"Links": null,
"MacAddress": "fa:16:3e:3a:2e:04",
"NetworkID": "bd84d27c-8909-4dcc-a9cf-7dca5453f55c"
}
},
"PortMapping": null,
"Ports": {
"443/tcp": [
{
"HostIp": "169.46.22.55",
"HostPort": "443"
}
],
"80/tcp": [
{
"HostIp": "169.46.22.55",
"HostPort": "80"
}
]
},
"PublicIpAddress": "169.46.22.55"
},
"Path": "date",
"ResolvConfPath": "/etc/resolv.conf",
"State": {
"Error": "",
"ExitCode": 0,
"FinishedAt": "0001-01-01T00:00:00Z",
"Ghost": "",
"Pid": 1,
"Running": true,
"StartedAt": "2017-01-11T06:22:54.000000000Z",
"Status": "Running"
},
"Volumes": {},
"VolumesRW": {}
}
]
You can review information in this page:
https://console.ng.bluemix.net/docs/containers/container_linking.html
I am afraid the the --link is incorrect and you will may have to ensure alias and name are correct.
This command output should help you:
cf ic inspect recipient_container_name
I'm having some strange issues with Docker on Mac. When I set up a container I am unable to access it via the containers IP address.
I installed Docker, along with Docker Quickstart Terminal. I've created a basic Dockerfile to test:
FROM ubuntu:14.04
MAINTAINER Me <me#gmail.com>
RUN apt-get update
RUN apt-get install -y nginx
RUN echo "Testing" > /usr/share/nginx/html/index.html
CMD ["nginx", "-g", "daemon off;"]
EXPOSE 80
I build with:
docker build -t james/nginx .
And then run with:
docker run -d james/nginx
I didn't use -p 80:8080 in this instance because at the moment I'm just trying to figure out why I can't access via the containers IP. I can't even ping it.
The container has been giving the title admiring_snyder (Got to love Docker's naming scheme). So I run docker inspect admiring_snyder to get the machines IP address:
[
{
"Id": "2d9ac50726ea5d20905c50f2453aa20cc46eebbcac21966d7cdb29a469ad3c7f",
"Created": "2016-03-14T18:22:24.179971826Z",
"Path": "nginx",
"Args": [
"-g",
"daemon off;"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 6837,
"ExitCode": 0,
"Error": "",
"StartedAt": "2016-03-14T18:22:24.245675122Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:921ad9259637823006e092e9ee6441a410fd1c60f2d599ace0ad8a3200d170c7",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/2d9ac50726ea5d20905c50f2453aa20cc46eebbcac21966d7cdb29a469ad3c7f/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/2d9ac50726ea5d20905c50f2453aa20cc46eebbcac21966d7cdb29a469ad3c7f/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/2d9ac50726ea5d20905c50f2453aa20cc46eebbcac21966d7cdb29a469ad3c7f/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/2d9ac50726ea5d20905c50f2453aa20cc46eebbcac21966d7cdb29a469ad3c7f/2d9ac50726ea5d20905c50f2453aa20cc46eebbcac21966d7cdb29a469ad3c7f-json.log",
"Name": "/admiring_snyder",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"ShmSize": 67108864,
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"KernelMemory": 0,
"Memory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [],
"Config": {
"Hostname": "2d9ac50726ea",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"Image": "james/nginx",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGTERM"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "aab80a46210e9ad79b53c60294912ed57a77968ac3178d0cf32ad40f2207e236",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": null
},
"SandboxKey": "/var/run/docker/netns/aab80a46210e",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "f5610deaced494b6a6c692a6e79bbe838f04574bb95f86b3c2b688477f724087",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:04",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "af5e68119aa41c3fbae80be8760b9382773533ae2c971253970740083ac9e202",
"EndpointID": "f5610deaced494b6a6c692a6e79bbe838f04574bb95f86b3c2b688477f724087",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:04"
}
}
}
}
]
Which shows the IP address:
"IPAddress": "172.17.0.4"
I am unable to connect to this IP address. I have a feeling it's something to do with docker being ran on a VM (obviously there's no alternative to this). But, I've no idea how to solve it.
The VM has the IP 192.168.99.100. I got this from docker-machine ip default.
Any advice?
You can launch the image with a port mapping;
docker run -d -p 8080:80 james/nginx
This will map port 8080 on the docker vm to port 80 in the docker container as can be seen in docker ps under PORTS;
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
6c8b6d1a7d3d james/nginx "nginx -g 'daemon off" About a minute ago Up About a minute 0.0.0.0:8080->80/tcp focused_spence
In your case, http://192.168.99.100:8080 will show your test page.
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