Unable to ping docker container - docker

New to docker on mac osx. I am building a ubuntu image from the base phusion image to use as a git server. Using the following file to install the base and needed software. This works great. However, I am unable to ping the machine.
EDIT
I am unable to ping the machine. I can run the image and see the container in the ps command. I can also exec bash into it.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
54e4cef78445 git-ssh_img "/usr/sbin/sshd -D" 44 minutes ago Up 44 minutes 22/tcp git-ssh
The following also works
docker exec -it 54e4cef78445 ping www.google.com
PING www.google.com (173.194.219.147) 56(84) bytes of data.
64 bytes from ya-in-f147.1e100.net (173.194.219.147): icmp_seq=1 ttl=61 time=65.1 ms
64 bytes from ya-in-f147.1e100.net (173.194.219.147): icmp_seq=2 ttl=61 time=67.1 ms
Dockerfile:
# Use phusion/baseimage as base image. To make your builds reproducible, make
# sure you lock down to a specific version, not to `latest`!
# See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md for
# a list of version numbers.
FROM phusion/baseimage:0.9.18
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
# ...put your own build instructions here...
ENV TERM xterm
RUN apt-get -y update
RUN apt-get -y install openssh-server
RUN apt-get -y install git \
libxml2-dev \
python \
build-essential \
make \
gcc \
python-dev \
python-pip
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Setting openssh
# RUN mkdir /var/run/sshd
RUN sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config
# Adding git user
RUN adduser --system git
RUN mkdir -p /home/git/.ssh
# Clearing and setting authorized ssh keys
RUN echo '' > /home/git/.ssh/authorized_keys
RUN echo 'First key' >> /home/git/.ssh/authorized_keys
# RUN echo 'Second SSH public key' >> /home/git/.ssh/authorized_keys
# ...
# Updating shell to bash
RUN sed -i s#/home/git:/bin/false#/home/git:/bin/bash# /etc/passwd
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Inspect command:
[
{
"Id": "54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2",
"Created": "2015-12-10T21:01:16.683875853Z",
"Path": "/usr/sbin/sshd",
"Args": [
"-D"
],
"State": {
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 13930,
"ExitCode": 0,
"Error": "",
"StartedAt": "2015-12-10T21:01:16.763739339Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "b2c6f9604ceca1e112dc0560aa4d0c50596d27c80256c544613f1d6badf6ccda",
"NetworkSettings": {
"Bridge": "",
"EndpointID": "87f12f9b527f3e0d7f823f1e2c88b0d0e860ff2d1687568d0a15cfa9fdfe22c3",
"Gateway": "172.17.42.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"HairpinMode": false,
"IPAddress": "172.17.0.26",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:1a",
"NetworkID": "a60ea78a8239baed013f9bfb1b2719a599ddef7745170e3c17eeab743a391ebe",
"PortMapping": null,
"Ports": {
"22/tcp": null
},
"SandboxKey": "/var/run/docker/netns/54e4cef78445",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null
},
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2-json.log",
"Name": "/git-ssh",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"MemorySwappiness": -1,
"Privileged": false,
"PortBindings": {},
"Links": null,
"PublishAllPorts": false,
"Dns": null,
"DnsSearch": null,
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "default",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"GroupAdd": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": "",
"ConsoleSize": [
0,
0
]
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [],
"Config": {
"Hostname": "54e4cef78445",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"22/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm"
],
"Cmd": [
"/usr/sbin/sshd",
"-D"
],
"Image": "git-ssh_img",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
}
}
]

As mentioned in "Can't visit http://172.17.0.2:5000 after starting docker registry", you cannot use the internal IP made for container-to-container communication.
You need to use the IP returned by $(docker-machine ip <yourMachine>) to actually ping the machine which runs your container.
Update February 2017, docker 1.13+: as commented by kboom, you now have Docker for Mac which uses a lightweight hypervisor (HyperKit), which allows to be bound to localhost (but still you cannot visit internal addresses).

Related

No such file or directory on any executable file in docker

I try to run a copy of ls from /bin (and tried on any executable file that isn't in /bin in a container) and get the error.
docker run -v ~/Desktop/test:/test alpine:latest /test/ls
exec /test/ls: no such file or directory
When I run another command I can see that file.
docker run -v ~/Desktop/test:/test alpine:latest ls /test
ls
I try to set chmode +x on this file, but don't get any changes. Changing image doesn't have any influation too. I've updated docker and all packaged by apt-get update && apt-get upgrade.
I use Ubuntu 20.04.3 LTS.
Docker version 20.10.17, build 100c701
Inspect
{
"Id": "abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33",
"Created": "2022-06-13T19:59:49.630474765Z",
"Path": "/test/ls",
"Args": [],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 1,
"Error": "",
"StartedAt": "2022-06-13T19:59:50.017551978Z",
"FinishedAt": "2022-06-13T19:59:50.016401363Z"
},
"Image": "sha256:0ac33e5f5afa79e084075e8698a22d574816eea8d7b7d480586835657c3e1c8b",
"ResolvConfPath": "/var/lib/docker/containers/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33/hostname",
"HostsPath": "/var/lib/docker/containers/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33/hosts",
"LogPath": "/var/lib/docker/containers/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33/abd66c400e6f58313d71c63c92688472874cdd4393d42e22df23a90264083b33-json.log",
"Name": "/cranky_pare",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/home/egor/Desktop/test:/test"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"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/115140c86b11eb773f30d2329ec05388224e75dfbcef9977c87bb3f0e32e8769-init/diff:/var/lib/docker/overlay2/22348355d634b9183f798e9622f71809a9a62a7c6accdf723aa72d979e3ba7f4/diff",
"MergedDir": "/var/lib/docker/overlay2/115140c86b11eb773f30d2329ec05388224e75dfbcef9977c87bb3f0e32e8769/merged",
"UpperDir": "/var/lib/docker/overlay2/115140c86b11eb773f30d2329ec05388224e75dfbcef9977c87bb3f0e32e8769/diff",
"WorkDir": "/var/lib/docker/overlay2/115140c86b11eb773f30d2329ec05388224e75dfbcef9977c87bb3f0e32e8769/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/home/egor/Desktop/test",
"Destination": "/test",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "abd66c400e6f",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/test/ls"
],
"Image": "alpine:latest",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "fb64f195f203033f02b9c5555e0b1d2cdd2819f3ac12f3046416f8e13378bc3d",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/fb64f195f203",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "cb261cd6eca2ddb567984e2d7d9e6df14008c774d73f0d76129da6c8edc6955c",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
},
"CreatedTime": 1655150389630
}
The program binary itself is (in most cases) not self-sufficient; instead, it depends on a number of dynamic libraries (usually at least a C standard library) and a dynamic linker (also known as the interpreter), which knows how to load the binary into the memory and to link it with these libraries.
The information about what linker the system has to use to launch the specific program and which libraries the program requires is stored inside the program binary itself. You may easily extract this information using tools like ldd and readelf. For example, this is how you may find all the stuff /bin/ls needs to run successfully:
$ ldd /bin/ls
linux-vdso.so.1 (0x00007ffec7b46000)
libcap.so.2 => /usr/lib/libcap.so.2 (0x00007f805384c000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f8053642000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f80538ae000)
Or, more verbosely:
$ readelf -a /bin/ls
...
Program Headers:
Type Offset VirtAddr PhysAddr
...
INTERP 0x0000000000000318 0x0000000000000318 0x0000000000000318
0x000000000000001c 0x000000000000001c R 0x1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
...
Dynamic section at offset 0x22a58 contains 28 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libcap.so.2]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
Note: my examples are taken from Arch box, so your results may be different, yet close to this. The main point here is that the binary relies on ld-linux, which is true for both Arch and Ubuntu (see below).
When you ask the kernel to execute ls, it reads the program binary, looks for the linker the program requires (/lib64/ld-linux-x86-64.so.2) in the filesystem and runs it. The linker then loads ls and all its dependencies into the memory; only after this the code of ls itself is executed.
The problem is that different Linux distributions (and different versions of them) have different environments. While it is common for distros to use GNU libc (glibc) as the C standard library and its ld-linux as the linker, there also are distros using other libc variants and other linkers. Alpine is one of such distros: it uses musl libc and its own linker ld-musl:
$ docker run -it alpine
/ # ldd /bin/ls
/lib/ld-musl-x86_64.so.1 (0x7f40c772d000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f40c772d000)
This means that Alpine does not have /lib64/ld-linux-x86-64.so.2 file (by default; see Running glibc programs). That is why running ls built for glibc-based system (Ubuntu in your case) inside an Alpine container fails: the kernel reads the binary, learns that it needs /lib64/ld-linux-x86-64.so.2 to load this program, and finds no such file inside the filesystem.
When the kernel is unable to find the interpreter requested by the program, it returns the same error as when you ask it to execute the non-existent file:
man 2 execve
...
ENOENT The file pathname or a script or ELF interpreter does not exist.
This is why you get no such file or directory, which is somewhat misleading, as it does not say which file is not found — the linker, not the program itself.
Given that ls does not have lots of dependencies, chances are good that the trick you try to do will work with containers having glibc-based systems inside:
$ docker run -it -v /bin/ls:/test/ls alpine /test/ls
exec /test/ls: no such file or directory
...
$ docker run -it -v /bin/ls:/test/ls ubuntu /test/ls
bin dev home lib32 libx32 mnt proc run srv test usr
boot etc lib lib64 media opt root sbin sys tmp var
...
$ docker run -it -v /bin/ls:/test/ls archlinux /test/ls
bin dev home lib64 opt root sbin sys tmp var
boot etc lib mnt proc run srv test usr
However, running host binaries inside the container is not what you are supposed to do and there is no guarantee that things won't go haywire, so make sure you really know what you do when employing such tricks.

Docker running on a amazonlinux:2 with an apache webserver returns 503 service unavailable

Setting up a docker container containing a apache webserver running on a linux OS.
I am trying to setup a docker environment where i run an apache webserver at a amazonlinux:2 OS through docker. I am able to set up everything but when i load the url on localhost it returns a "503 service unavailable". I have tried to switch ports etc. Nothing works even though this is the modules etc. used for deploying my servers non-docker. I know stackoverflow isn't meant for very code specific issues i just can't seem to solve this one on my own. Thanks in advance.
The following that might be relevant: Docker inspect
[
{
"Id": "8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de",
"Created": "2020-04-30T11:25:00.7273382Z",
"Path": "/usr/sbin/init",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 33131,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-04-30T11:25:02.2676346Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:ba3c5108c23dcee592b14fe824776b562fe64b9685e8930e0ba365230488c558",
"ResolvConfPath": "/var/lib/docker/containers/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de/hostname",
"HostsPath": "/var/lib/docker/containers/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de/hosts",
"LogPath": "/var/lib/docker/containers/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de/8f9997578a8f16655e7e1c2c32b4be5ec06b79a886c73dd8151c6b36993c99de-json.log",
"Name": "/webserver",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "test_default",
"PortBindings": {
"8080/tcp": [
{
"HostIp": "",
"HostPort": "8080"
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": true,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": [
"label=disable"
],
"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,
"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": null,
"ReadonlyPaths": null
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/632952313b6924721dbb70ce572bddc5960412d27c7c97e55a5e988fda2e4340-init/diff:/var/lib/docker/overlay2/7928f2a813c8abbff2c73e9dfcf0f6608e6da85cd775600d683025c83d3ad57c/diff:/var/lib/docker/overlay2/81ad8aaf872ad9aebfc09ed470c0f1b7d2be073c7b54acffb46262e08c4da626/diff:/var/lib/docker/overlay2/175c01b27dbb0c18765431cfe8217c49ce2dc5ddc2c690fac98a7c06f7954a86/diff:/var/lib/docker/overlay2/db4dbbd7229b9024e9e8d6a4a04cb06e7cb11e106b266831237da74f64e908a9/diff:/var/lib/docker/overlay2/43434aaa5b69556dfa16e8bf5eed24be80453ba2b9b9aa46293c92676ca895fd/diff:/var/lib/docker/overlay2/4abf428a00de2f5b3d69fe5ad95840eb23bafab9f3ce1dbe338816a64afb8b45/diff:/var/lib/docker/overlay2/f29b5cfeaa8f70f63cb823574f3c12ae7225171d880f52f9152d829510785c37/diff:/var/lib/docker/overlay2/009e8af3a21902fb29a7dd34bf70bf2e9a18e92d4a19d61af4efedc3a418f47d/diff:/var/lib/docker/overlay2/5f253c50fd411d5b6feb6b7530c4063074f825bd7d5638d9d3fe24f48d9fc15d/diff:/var/lib/docker/overlay2/c09ac469770ad1a64ad6d2cf8e329758dc9c396a10284f533fd4e88abb8b7504/diff:/var/lib/docker/overlay2/f23f1a035669c8d634ec2e6d6526314194d102c3e923b7c192ce3275e3a79b6e/diff:/var/lib/docker/overlay2/214a494e5be1bca7b560ea3c2767fc26af350cdce8a717c2c325bc124e8e2010/diff:/var/lib/docker/overlay2/43b742e71bf54d2f9beb64ad80b5737f4892d0078213d5fb455e77da0816f0fd/diff:/var/lib/docker/overlay2/31310c16a674414fdb27f9792eeae7301618d960a322d899baa77b7fa89db239/diff:/var/lib/docker/overlay2/6fec2d57bdf41b2bac187ae31518c9a3dda15af2ba2397e1524a96fb6b6df036/diff:/var/lib/docker/overlay2/eb1092c999afd90a70bc365518a95bbaf198f8462db80e5fa959cf2f1f60ec23/diff:/var/lib/docker/overlay2/cf7cf93961372b8bbf2fe3a1b3ad849ffce0cae129b7c89b5d5a182ce397da12/diff:/var/lib/docker/overlay2/330df7c9d56f024ab1c9d4157c128d709b37272001d4abbf8b6871c6b9089f15/diff",
"MergedDir": "/var/lib/docker/overlay2/632952313b6924721dbb70ce572bddc5960412d27c7c97e55a5e988fda2e4340/merged",
"UpperDir": "/var/lib/docker/overlay2/632952313b6924721dbb70ce572bddc5960412d27c7c97e55a5e988fda2e4340/diff",
"WorkDir": "/var/lib/docker/overlay2/632952313b6924721dbb70ce572bddc5960412d27c7c97e55a5e988fda2e4340/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "8f9997578a8f",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"443/tcp": {},
"8080/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": null,
"Image": "test_webserver_setup",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/usr/sbin/init"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "f8dfaed17cde38b55e050b86a43bb0dd5429ad6c21baad83b389a19df88869b9",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "test",
"com.docker.compose.project.config_files": "docker-compose.yaml",
"com.docker.compose.project.working_dir": "/private/docker/test",
"com.docker.compose.service": "webserver_setup",
"com.docker.compose.version": "1.25.4"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "46e724f336d8d865616f32abcc74d1ddc7dd7bd8cb15afa84992c68f38e65c8c",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3306/tcp": null,
"443/tcp": null,
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"SandboxKey": "/var/run/docker/netns/46e724f336d8",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"test_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"webserver_setup",
"8f9997578a8f"
],
"NetworkID": "d7c1b2428c7c8ffa4d64079053a90edbbeead91d334edee406fd848a653d0304",
"EndpointID": "1721124b84f8dd31868ebacf4ea0e86c3fc627d769d157003792744e7e1e3394",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02",
"DriverOpts": null
}
}
}
}
]
Here is my docker-compose file which i run with the "docker-compose up" command:
version: "3.0"
services:
webserver_setup:
stdin_open: true
tty: true
privileged: true
build:
context: .
dockerfile: webserver_dockerfile
container_name: webserver
ports:
- 8080:8080
And the webserver_dockerfile
FROM amazonlinux:2
COPY ./source/ /var/www/html
#ENTRYPOINT ["/"]
RUN yum install sudo -y
RUN sudo yum update -y
RUN sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
RUN sudo yum install -y httpd mariadb-server
#install dependencies
RUN yum update -y && yum install -y \
initscripts \
mod_ssl \
gcc \
memcached \
openssl-devel \
php72-bcmath \
php72-cli \
php72-common \
php72-dba \
php72-dbg \
php72-devel \
php72-enchant \
php72-fpm \
php72-gd \
php72-gmp \
php72-imap \
php72-intl \
php72-json \
php72-ldap \
php72-mbstring \
php72-mcrypt \
php72-mysqlnd \
php72-odbc \
php72-opcache \
php72-pdo \
php72-pdo-dblib \
php72-pecl-igbinary \
php72-pecl-imagick \
php72-pecl-memcached \
php72-pecl-oauth \
php72-pecl-ssh2 \
php72-pecl-uuid \
php72-pecl-yaml \
php72-pgsql \
php72-process \
php72-pspell \
php72-recode \
php72-snmp \
php72-soap \
php72-tidy \
php72-xml \
php72-xmlrpc \
php72-zip \
php7-pear \
mysql57-server \
mongodb-org \
nano \
man \
&& yum clean all
#setup webserver and access to document directory
RUN sudo systemctl enable httpd
RUN sudo usermod -a -G apache root
RUN sudo chown -R root:apache /var/www
RUN sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
RUN find /var/www -type f -exec sudo chmod 0664 {} \;
#remove default config and prepare server with custom config
#RUN echo "ServerName gamingbuddy.local" >> /etc/httpd/conf/httpd.conf
RUN sed -i 's/Listen 80/Listen 0.0.0.0:8080/' /etc/httpd/conf/httpd.conf
RUN sed -i '/<Directory \"\/var\/www\">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
RUN sed -i '/<Directory \"\/var\/www\/html\">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
RUN touch /etc/httpd/conf/vhost.conf
RUN printf "<VirtualHost *:8080> \
ServerName localhost \
<Proxy *> \
#Allow from localhost \
Order deny,allow \
Allow from all \
</Proxy> \
ProxyPass / http://172.19.0.1:8080/ retry=0 \
</VirtualHost>"
RUN rm /etc/httpd/conf.d/welcome.conf
RUN echo "Include '/etc/httpd/conf/vhost.conf'" >> /etc/httpd/conf/httpd.conf
EXPOSE 8080
EXPOSE 443
EXPOSE 3306
ENTRYPOINT ["/usr/sbin/init"]
#servers are started during build file setup
I get an error regarding fastGCI process manager that fails to start and a remount of root and kernel file system. These are the errors and error codes i get:
bash-4.2# systemctl status systemd-remount-fs.service
● systemd-remount-fs.service - Remount Root and Kernel File Systems
Loaded: loaded (/usr/lib/systemd/system/systemd-remount-fs.service; static; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-05-01 12:10:27 UTC; 2min 36s ago
Docs: man:systemd-remount-fs.service(8)
http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
Process: 23 ExecStart=/usr/lib/systemd/systemd-remount-fs (code=exited, status=1/FAILURE)
Main PID: 23 (code=exited, status=1/FAILURE)
May 01 12:10:27 0ce19e8b1c10 systemd-remount-fs[23]: mount: /: can't find LABEL=/.
May 01 12:10:27 0ce19e8b1c10 systemd[1]: systemd-remount-fs.service: main process exited, code=exited, status=1/FAILURE
May 01 12:10:27 0ce19e8b1c10 systemd[1]: Failed to start Remount Root and Kernel File Systems.
May 01 12:10:27 0ce19e8b1c10 systemd[1]: Unit systemd-remount-fs.service entered failed state.
May 01 12:10:27 0ce19e8b1c10 systemd[1]: systemd-remount-fs.service failed.
Error 2:
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-05-01 12:10:33 UTC; 13min ago
Process: 253 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
Main PID: 253 (code=exited, status=78)
May 01 12:10:32 0ce19e8b1c10 systemd[1]: Starting The PHP FastCGI Process Manager...
May 01 12:10:33 0ce19e8b1c10 php-fpm[253]: [01-May-2020 12:10:33] ERROR: [pool www] failed to read the ACL of the socket '/run/php-fpm/www.sock': Operation not supported (95)
May 01 12:10:33 0ce19e8b1c10 php-fpm[253]: [01-May-2020 12:10:33] ERROR: FPM initialization failed
May 01 12:10:33 0ce19e8b1c10 systemd[1]: php-fpm.service: main process exited, code=exited, status=78/n/a
May 01 12:10:33 0ce19e8b1c10 systemd[1]: Failed to start The PHP FastCGI Process Manager.
May 01 12:10:33 0ce19e8b1c10 systemd[1]: Unit php-fpm.service entered failed state.
May 01 12:10:33 0ce19e8b1c10 systemd[1]: php-fpm.service failed.

My Docker container does not have IP address. Why?

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.

Docker OSX Unable to Access Container via IP Address

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.

ASP.NET docker image exposed ports are closed

I have added EXPOSE to the ASPNET Dockerfile and build an image from it however the port exposed in the docker file is always closed? do I need to download a specific package to allow ports to open on this image.
Dockerfile
FROM debian:jessie
ENV DNX_VERSION 1.0.0-beta8
ENV DNX_USER_HOME /opt/dnx
RUN apt-get -qq update && apt-get -qqy install unzip curl libicu-dev libunwind8 gettext libssl-dev libcurl3-gnutls zlib1g && rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_USER_HOME=$DNX_USER_HOME DNX_BRANCH=v$DNX_VERSION sh
RUN bash -c "source $DNX_USER_HOME/dnvm/dnvm.sh \
&& dnvm install $DNX_VERSION -alias default -r coreclr \
&& dnvm alias default | xargs -i ln -s $DNX_USER_HOME/runtimes/{} $DNX_USER_HOME/runtimes/default"
# Install libuv for Kestrel from source code (binary is not in wheezy and one in jessie is still too old)
# Combining this with the uninstall and purge will save us the space of the build tools in the image
RUN LIBUV_VERSION=1.4.2 \
&& apt-get -qq update \
&& apt-get -qqy install autoconf automake build-essential libtool \
&& curl -sSL https://github.com/libuv/libuv/archive/v${LIBUV_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \
&& cd /usr/local/src/libuv-$LIBUV_VERSION \
&& sh autogen.sh && ./configure && make && make install \
&& rm -rf /usr/local/src/libuv-$LIBUV_VERSION \
&& ldconfig \
&& apt-get -y purge autoconf automake build-essential libtool \
&& apt-get -y autoremove \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 5003
ENV PATH $PATH:$DNX_USER_HOME/runtimes/default/bin
Please note that other images exposing ports like mongodb and nginx are working fine and their exposed ports are open. It is only this image that I am struggling with
docker inspect output
[
{
"Id": "46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a",
"Created": "2015-11-09T10:59:21.613690009Z",
"Path": "/bin/bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 21337,
"ExitCode": 0,
"Error": "",
"StartedAt": "2015-11-09T10:59:21.800924128Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "2e1b81c113a2a2ba84935be470f9b02ee22f23649136d4408f0340f385e67fc1",
"ResolvConfPath": "/var/lib/docker/containers/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a/hostname",
"HostsPath": "/var/lib/docker/containers/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a/hosts",
"LogPath": "/var/lib/docker/containers/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a/46865fae677bc52a8d7affbd53d8ed3da941fd2d8276514dcbcdebfc3b5d666a-json.log",
"Name": "/aspnet",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": [
"181b80dd7744fa16f6e720234c9a9d629b4558cfe84c6e43067f827125a78915"
],
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"MemorySwappiness": -1,
"Privileged": false,
"PortBindings": {},
"Links": null,
"PublishAllPorts": false,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "default",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"GroupAdd": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": "",
"ConsoleSize": [
0,
0
],
"VolumeDriver": ""
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [],
"Config": {
"Hostname": "46865fae677b",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"5003/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/dnx/runtimes/default/bin",
"DNX_VERSION=1.0.0-beta8",
"DNX_USER_HOME=/opt/dnx"
],
"Cmd": [
"/bin/bash"
],
"Image": "aspnet:try1",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGTERM"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "b4d6098c499133f57a7bf90c22cc78f603a4857b7baeba652358e8c825564f16",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"5003/tcp": null
},
"SandboxKey": "/var/run/docker/netns/b4d6098c4991",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "48fd94eabaed4216f1f617f046c1495a77f349c163b4bd8e81f2c7c879968d64",
"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": {
"EndpointID": "48fd94eabaed4216f1f617f046c1495a77f349c163b4bd8e81f2c7c879968d64",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:04"
}
}
}
}
]
nmap port scan for 5003
nmap -p 5003 172.17.0.4
Starting Nmap 6.40 ( http://nmap.org ) at 2015-11-09 06:51 EST
Nmap scan report for 172.17.0.4
Host is up (0.00011s latency).
PORT STATE SERVICE
5003/tcp closed filemaker
MAC Address: 02:42:AC:11:00:04 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 0.46 seconds

Resources