Volume mounting not working with docker-compose (MacOS) - docker

I am relatively new to Docker and I am attempting to build a single custom image from my Dockerfile using docker-compose.
Dockerfile
FROM continuumio/anaconda3
#create a directory
WORKDIR /home/docker/qts
#copy the dependencies file
COPY ./requirements.txt .
#install necessary packages
RUN pip install --no-cache-dir -r requirements.txt
#Expose ports
EXPOSE 5000
docker-compose.yml
version: "3.8"
services:
pyimg:
build: .
ports:
- 5000:5000
volumes:
- $HOME/Documents/qts:/home/docker/qts
My issue
Running docker-compose build gives me no errors. When I execute docker run -it <image_name> bash and navigate into the directory /home/docker/qts, the directory does not mirror the local directory.
A docker inspect also shows that the volumes are not mounted (and that the ports that I have exposed have also not been mapped to the local ports!) What am I missing here?
Thank you for your input.
[
{
"Id": "cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2",
"Created": "2021-02-27T14:44:14.9474339Z",
"Path": "bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 2712,
"ExitCode": 0,
"Error": "",
"StartedAt": "2021-02-27T14:44:15.2955648Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:332985fd4830584b0356f0bf28500f5b951f7ae1fb0e0b5d774c264e28a900e3",
"ResolvConfPath": "/var/lib/docker/containers/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2/hostname",
"HostsPath": "/var/lib/docker/containers/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2/hosts",
"LogPath": "/var/lib/docker/containers/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2/cc506e95df8788349090b310bfa6965b56dbb9e218efe4a9024eb2f502a2d2f2-json.log",
"Name": "/determined_aryabhata",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"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/a802a922e08dd98e4dcebea8253d2457393aa5380ba31698087ebab7c20c7420-init/diff:/var/lib/docker/overlay2/7fd10d3a3749cfbcfb8ba4bffbe4d5ec9b70c0244f18d8bcbc10e50526fa2836/diff:/var/lib/docker/overlay2/a951e71a24b2c5635f34fbac57fe02e902ffa55928854bd63918c3a0eac8bd6a/diff:/var/lib/docker/overlay2/67defaf9804e20dbe3bb9b06a68301b527cebf5ad15103d129b564b4678f65eb/diff:/var/lib/docker/overlay2/7e88aebe633878bdd3fe36eb842259d1e898f64fd6937a47ac7b32cb77958fe0/diff:/var/lib/docker/overlay2/61c831913d4448f0efa8b78852181b45c993aa6d5d6b1d7b01e85f936121ab4d/diff:/var/lib/docker/overlay2/dc34279b6529ec9d0123de5a46520de90775fe9ad0d87f8e8a572085df7bf3d3/diff",
"MergedDir": "/var/lib/docker/overlay2/a802a922e08dd98e4dcebea8253d2457393aa5380ba31698087ebab7c20c7420/merged",
"UpperDir": "/var/lib/docker/overlay2/a802a922e08dd98e4dcebea8253d2457393aa5380ba31698087ebab7c20c7420/diff",
"WorkDir": "/var/lib/docker/overlay2/a802a922e08dd98e4dcebea8253d2457393aa5380ba31698087ebab7c20c7420/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "cc506e95df87",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"5000/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",

You can not see with docker run you can check like below;
version: "3.8"
services:
pyimg:
build: .
ports:
- 5000:5000
volumes:
- $HOME/Documents/qts:/home/docker/qts
command:
- /bin/bash
- -c
- sleep 60
With docker ps find your container id than;
docker exec -it ID /bin/bash
And
ls

Related

ASP dotnet core web app container running but not opening in browser. using .net 6.0

ASP dotnet core web app container running but not opening in browser. using .net 6.0
i tried http://localhot
container port. please let me know where i am doing mistake.
Below i am sharing my Dockerfile and docker inpect result.
#workdir consider in app folder
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
#restoring nuget package for csproj files
COPY *.csproj ./
RUN dotnet restore
#copy all project files
COPY . ./
RUN dotnet publish -c Release -o out
#creating running image
FROM mcr.microsoft.com/dotnet/sdk:6.0
WORKDIR /app
COPY --from=build-env /app/out/ .
EXPOSE 80
ENTRYPOINT ["dotnet","dotnetpracticeapp2.dll"]
Docker container inspect output
11:11
my dotnet core web .net 6.0 version Container is running but not opening in browser,here is my some details
#workdir consider in app folder
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
#restoring nuget package for csproj files
COPY *.csproj ./
RUN dotnet restore
#copy all project files
COPY . ./
RUN dotnet publish -c Release -o out
#creating running image
FROM mcr.microsoft.com/dotnet/sdk:6.0
WORKDIR /app
COPY --from=build-env /app/out/ .
EXPOSE 80
ENTRYPOINT ["dotnet","dotnetpracticeapp2.dll"]
Docker container inspect output
{
"Id": "9fc1f41590c7e25ddd5ec66c542afac89c00ee9cef9c5148368f39c8a04248ce",
"Created": "2022-03-11T17:24:11.7749279Z",
"Path": "dotnet",
"Args": [
"dotnetpracticeapp2.dll"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1304,
"ExitCode": 0,
"Error": "",
"StartedAt": "2022-03-12T18:00:28.6816882Z",
"FinishedAt": "2022-03-12T17:55:41.1098514Z"
},
"Image": "sha256:7d342807b790f1c7a2470db3ae47a85849bd8354939c3e4659a24d1ee388799f",
"ResolvConfPath": "/var/lib/docker/containers/9fc1f41590c7e25ddd5ec66c542afac89c00ee9cef9c5148368f39c8a04248ce/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/9fc1f41590c7e25ddd5ec66c542afac89c00ee9cef9c5148368f39c8a04248ce/hostname",
"HostsPath": "/var/lib/docker/containers/9fc1f41590c7e25ddd5ec66c542afac89c00ee9cef9c5148368f39c8a04248ce/hosts",
"LogPath": "/var/lib/docker/containers/9fc1f41590c7e25ddd5ec66c542afac89c00ee9cef9c5148368f39c8a04248ce/9fc1f41590c7e25ddd5ec66c542afac89c00ee9cef9c5148368f39c8a04248ce-json.log",
"Name": "/dotnetapp2",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
]
},
"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": [
16,
125
],
"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/5c6af7c62a17860faa1bccd6d57b064bc9639fbdc06dc200f12c63f0743fb0b7-init/diff:/var/lib/docker/overlay2/2fgcm3ps2hi5wuzj4nmid1gj4/diff:/var/lib/docker/overlay2/7g09cyks1ftmankkfn8rytjea/diff:/var/lib/docker/overlay2/43fbef426074496a5423ec4f2423857878095a252a5091db78cfe891af95ed3d/diff:/var/lib/docker/overlay2/dbf0cc5fcf1324ccac8470143b6b87a313e4df9a9aa344a9e600c968afcafa16/diff:/var/lib/docker/overlay2/41d81ab7ea010ecb9fac87a3b63d7183228ffc286bb2063690e5f7169f212d20/diff:/var/lib/docker/overlay2/3ee4f5439a2a5103f23ade1cde12fcf6ca386e1f2affbbd9337769ef1ef0ecd4/diff:/var/lib/docker/overlay2/15bdfbb6aecdf14bbe0b554c229ef08c4bd578c0ac2c6c002c419344d198df1a/diff:/var/lib/docker/overlay2/f8e7d9c155d0f25cd0076112aa911496febe9ca4e7a9ace2bf7a09b80f0c0bd5/diff:/var/lib/docker/overlay2/e1c521705e01879f23dadea31f56fb5ad6693acc5ddacec190216556cb8ba742/diff:/var/lib/docker/overlay2/095c04af29c37be9e84dbba0d0b7aadf6c0c91fbeca2a2fa1843815b0ebf9cd0/diff",
"MergedDir": "/var/lib/docker/overlay2/5c6af7c62a17860faa1bccd6d57b064bc9639fbdc06dc200f12c63f0743fb0b7/merged",
"UpperDir": "/var/lib/docker/overlay2/5c6af7c62a17860faa1bccd6d57b064bc9639fbdc06dc200f12c63f0743fb0b7/diff",
"WorkDir": "/var/lib/docker/overlay2/5c6af7c62a17860faa1bccd6d57b064bc9639fbdc06dc200f12c63f0743fb0b7/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "9fc1f41590c7",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"ASPNETCORE_URLS=",
"DOTNET_RUNNING_IN_CONTAINER=true",
"DOTNET_VERSION=6.0.3",
"ASPNET_VERSION=6.0.3",
"Logging__Console__FormatterName=",
"DOTNET_GENERATE_ASPNET_CERTIFICATE=false",
"DOTNET_NOLOGO=true",
"DOTNET_SDK_VERSION=6.0.201",
"DOTNET_USE_POLLING_FILE_WATCHER=true",
"NUGET_XMLDOC_MODE=skip",
"POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetSDK-Debian-11"
],
"Cmd": null,
"Image": "parshchakurkar/dotnetapp:1.21",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": [
"dotnet",
"dotnetpracticeapp2.dll"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "1788646d554f21bfed7a1c0be2c884f136bd7095aee00b10f36f1ce155225bc6",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "80"
},
{
"HostIp": "::",
"HostPort": "80"
}
]
},
"SandboxKey": "/var/run/docker/netns/1788646d554f",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "53d78ef8e764106367138ca777d419035a03219570a0a523875cf7157a8cd299",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "464a5c9c0dcba8adc13abe8ef9c2d4756a4b1525a92bfe643b4e2ef75b609d57",
"EndpointID": "53d78ef8e764106367138ca777d419035a03219570a0a523875cf7157a8cd299",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
please check and update where i am doing mistake
I presume docker command "docker run --rm -it -p 80:80 image ID"
Map port 80 on the local machine to port 80 in the container.
Please in the Internet browser key http://localhost: you build port 80 (EXPOSE 80)
if is in dockerfile add ENV ASPNETCORE_URLS=http://+:80
Please in the Internet browser key http://0.0.0.0:80/
Reference:https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images?view=aspnetcore-6.0

Why I don't see Tomcat after run docker tomcat?

I am quite new with Docker. I follow this tutorial: https://stackjava.com/docker/huong-dan-cai-apache-tomcat-bang-docker-sua-port-username-password.html
My command
docker pull tomcat
docker run -it tomcat
docker ps -a
docker inspect -f '{{json .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 5e55df1c76bb
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 5e55df1c76bb
docker inspect 5e55df1c76bb
docker inspect --format="{{json .NetworkSettings.Networks}}" 5e55df1c76bb
172.17.0.2
but I access: http://172.17.0.2:8080 see nothing
C:\Users\donhuvy>docker inspect 5e55df1c76bb
[
{
"Id": "5e55df1c76bb8dff9e423b7750b62594e150bb2468b033acad18ea9f7d445229",
"Created": "2020-10-05T16:02:40.7573065Z",
"Path": "catalina.sh",
"Args": [
"run"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 987,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-10-05T16:02:41.1437801Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:f796d3d2c1954864eae249749f0a17480fb446c22053f4451e2c3514c561638b",
"ResolvConfPath": "/var/lib/docker/containers/5e55df1c76bb8dff9e423b7750b62594e150bb2468b033acad18ea9f7d445229/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/5e55df1c76bb8dff9e423b7750b62594e150bb2468b033acad18ea9f7d445229/hostname",
"HostsPath": "/var/lib/docker/containers/5e55df1c76bb8dff9e423b7750b62594e150bb2468b033acad18ea9f7d445229/hosts",
"LogPath": "/var/lib/docker/containers/5e55df1c76bb8dff9e423b7750b62594e150bb2468b033acad18ea9f7d445229/5e55df1c76bb8dff9e423b7750b62594e150bb2468b033acad18ea9f7d445229-json.log",
"Name": "/recursing_mirzakhani",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"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": [
29,
125
],
"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/73d16111a45bdfadbd3504d2ce0c252f2fd5f03d7a7f1340b35f68179d06ff52-init/diff:/var/lib/docker/overlay2/4f4ba32e9f0e1ab529e63310679569d7dcc1e661711b9ee4318e2ee65891f994/diff:/var/lib/docker/overlay2/fce4dda91aa387a1637fcac186996c18e34f8972cc7556023a84ceed8f9547c6/diff:/var/lib/docker/overlay2/f57b2ab773944fe913da9c109de5d74d21f79c5f6b00e9362247916de89a480b/diff:/var/lib/docker/overlay2/1fb80e26e111dac4d0afd9cd069da39b0e4d6005f649fefc9f62786d644ef10c/diff:/var/lib/docker/overlay2/71d4caaff5263b8a146f8e512cdc94ddd5a64d0ce06aefd2806b17ba7b2bb1e1/diff:/var/lib/docker/overlay2/94bbeff68944707d4ec182874b3054e241f87f184cc73370fd2a4872cc7ee4f5/diff:/var/lib/docker/overlay2/ff0f6369023d7c463b55141759b930eadbeacb60dcb2f64b27bef652dffb754c/diff:/var/lib/docker/overlay2/0d067db196d1894c9685f3bd71d2f5ee6e321784de6ec2ccd8f2ce0744042083/diff:/var/lib/docker/overlay2/f9bd339ee715bbed03a969664abfe5aa89f39c22cb42a69d89a9a989edd17257/diff:/var/lib/docker/overlay2/a92a068cbd132637742e14d1df96c081342ba8ab10663ef87197058b39e618e5/diff",
"MergedDir": "/var/lib/docker/overlay2/73d16111a45bdfadbd3504d2ce0c252f2fd5f03d7a7f1340b35f68179d06ff52/merged",
"UpperDir": "/var/lib/docker/overlay2/73d16111a45bdfadbd3504d2ce0c252f2fd5f03d7a7f1340b35f68179d06ff52/diff",
"WorkDir": "/var/lib/docker/overlay2/73d16111a45bdfadbd3504d2ce0c252f2fd5f03d7a7f1340b35f68179d06ff52/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "5e55df1c76bb",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"8080/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/usr/local/tomcat/bin:/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"JAVA_HOME=/usr/local/openjdk-11",
"JAVA_VERSION=11.0.8",
"CATALINA_HOME=/usr/local/tomcat",
"TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
"LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
"GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23",
"TOMCAT_MAJOR=9",
"TOMCAT_VERSION=9.0.38",
"TOMCAT_SHA512=37117164c9ab985b4f3032deac9617cee01463f8822586a62a9c498d2720fac23a8207fcf7a76cea2fcb3c6f828ff12b7b31422316a7d92e707c3bd8d687e303"
],
"Cmd": [
"catalina.sh",
"run"
],
"Image": "tomcat",
"Volumes": null,
"WorkingDir": "/usr/local/tomcat",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "c2b2e13e21b94eb338ce47eb6f7319f719bd1d617fef7535d81f10210408be2a",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8080/tcp": null
},
"SandboxKey": "/var/run/docker/netns/c2b2e13e21b9",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "f9582dfa8c2818b7f9846bf45fe3b56e671ca89efd2adab77c512d958beede7d",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "85106b65ae7140fb90ba8edcb0247f2fcf904f84cd540e6689613b5615b95bb5",
"EndpointID": "f9582dfa8c2818b7f9846bf45fe3b56e671ca89efd2adab77c512d958beede7d",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
C:\Users\donhuvy>
How to see the result of Tomcat on web browser?
I think the tutorial you are referring to is a bit outdated. You can run the tomcat docker container using a command like
docker run --rm --name tomcat-server -p 8080:8080 tomcat:latest
Access tomcat at http://localhost:8080
Further information is here. You would initially get a 404 as the webapp folder is empty. You can refer to this documentation which should help in getting a basic Tomcat installation running. You can then follow from step 3 of the original tutorial you are refer to.
docker exec -it tomcat-server /bin/bash
mv webapps webapps2
mv webapps.dist/ webapps
exit

How to add additional dependencies to chrome standalone image

I am trying to run chrome container.
This works for me:
[practice]$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome
b7d63881869721fe66a4f00de4be7a3bfb8e922410776a7c35f827bfd08f9455
[practice]$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b7d638818697 selenium/standalone-chrome "/opt/bin/entry_poin…" 22 seconds ago Up 22 seconds 0.0.0.0:4444->4444/tcp lucid_sammet
But my requirement is to have an additional package inside my container, so i created a DockerFile
FROM selenium/standalone-chrome
FROM node:latest
RUN npm install --save #ffmpeg-installer/ffmpeg
And created a build using:
[practice]$ docker build -t mychrome:1.0 .
Sending build context to Docker daemon 15.34MB
Step 1/3 : FROM selenium/standalone-chrome
---> c84475653f71
Step 2/3 : FROM node:latest
---> a511eb5c14ec
Step 3/3 : RUN npm install --save #ffmpeg-installer/ffmpeg
---> Using cache
---> 2d04ced6065c
Successfully built 2d04ced6065c
Successfully tagged mychrome:1.0
But when i create container, it gets killed by itself.
[practice]$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm mychrome:1.0
1e6416ff6d232cc7fb1990ac5ae425af72d6456ec2a94d6b575431edb9e04211
[practice]$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Here are docker inspect:
[practice]$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1e6416ff6d23 mychrome:1.0 "docker-entrypoint.s…" 2 minutes ago Exited (0) 2 minutes ago compassionate_panini
b2dcd66a3f97 mychrome:1.0 "docker-entrypoint.s…" 2 minutes ago Created elegant_mcc
[practice]$ docker inspect 1e6416ff6d23
[
{
"Id": "1e6416ff6d232cc7fb1990ac5ae425af72d6456ec2a94d6b575431edb9e04211",
"Created": "2020-05-09T06:51:21.8510204Z",
"Path": "docker-entrypoint.sh",
"Args": [
"node"
],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-05-09T06:51:22.1525569Z",
"FinishedAt": "2020-05-09T06:51:22.331137Z"
},
"Image": "sha256:2d04ced6065c32a7f1e2d3d28988302b7e762533f7964b8bcbe344f05ba65fdc",
"ResolvConfPath": "/var/lib/docker/containers/1e6416ff6d232cc7fb1990ac5ae425af72d6456ec2a94d6b575431edb9e04211/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/1e6416ff6d232cc7fb1990ac5ae425af72d6456ec2a94d6b575431edb9e04211/hostname",
"HostsPath": "/var/lib/docker/containers/1e6416ff6d232cc7fb1990ac5ae425af72d6456ec2a94d6b575431edb9e04211/hosts",
"LogPath": "/var/lib/docker/containers/1e6416ff6d232cc7fb1990ac5ae425af72d6456ec2a94d6b575431edb9e04211/1e6416ff6d232cc7fb1990ac5ae425af72d6456ec2a94d6b575431edb9e04211-json.log",
"Name": "/compassionate_panini",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/dev/shm:/dev/shm"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"4444/tcp": [
{
"HostIp": "",
"HostPort": "4444"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"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/55f20b215a1ff36c8ebb1dff18cac13e9b0a8fb30d5e81a7bd98c8d259a53cde-init/diff:/var/lib/docker/overlay2/d9ffce8fb048fc9b3f06d8bf9722848e1c634fa62c6cddf3b81c8fd69f168d15/diff:/var/lib/docker/overlay2/ac6f63198e071b53404e7f46a18e442fbb3940bd1ab33689b14c3cefd0cec63f/diff:/var/lib/docker/overlay2/27e169d3a5ecd1eb5a1a169fd295b8bcb01c03bb0de80609bf1f8b807a922ab0/diff:/var/lib/docker/overlay2/1bc8d050ec3936a42bfc5274d3857b0b507245798226de02db185a4bed2ee505/diff:/var/lib/docker/overlay2/e51f7d0d89f2480c94a247f4fece58ba82ecf0139b3d066a7154f74ea196fb67/diff:/var/lib/docker/overlay2/6a241e18bf0fed51affe0f856b9a685d81db7ecd3b5e73754ce94d3a77e66173/diff:/var/lib/docker/overlay2/8c2950f8c31da7a939c93f9fe187c52eea8317a4b64ee2c3b75b09e2db924ce5/diff:/var/lib/docker/overlay2/1fce7515c1871f43e30f3761ef340c8a85fc7de0c3902299db206a2ba0461bd3/diff:/var/lib/docker/overlay2/84d7667120601df8ff0c8187d350fe3700611a7eb9294dde6d6ce8343150551d/diff:/var/lib/docker/overlay2/26c37b434064f095df1114f55e37487094c1efcd8c4bb7b40507da171553210c/diff",
"MergedDir": "/var/lib/docker/overlay2/55f20b215a1ff36c8ebb1dff18cac13e9b0a8fb30d5e81a7bd98c8d259a53cde/merged",
"UpperDir": "/var/lib/docker/overlay2/55f20b215a1ff36c8ebb1dff18cac13e9b0a8fb30d5e81a7bd98c8d259a53cde/diff",
"WorkDir": "/var/lib/docker/overlay2/55f20b215a1ff36c8ebb1dff18cac13e9b0a8fb30d5e81a7bd98c8d259a53cde/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/dev/shm",
"Destination": "/dev/shm",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "1e6416ff6d23",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"4444/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NODE_VERSION=14.1.0",
"YARN_VERSION=1.22.4"
],
"Cmd": [
"node"
],
"Image": "mychrome:1.0",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "c14a931bf5ad40900b83e8f1ee770d270765af1ff181ff610ed2b564d12e3f13",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/c14a931bf5ad",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "51bc10f592d1c05978822f1f5c8a108dffa0581fd6c639e73984bf0760831564",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
]
Please let me what is wrong here.
got it working by using this dockerfile:
FROM node:latest AS node_base
RUN echo "NODE Version:" && node --version
RUN echo "NPM Version:" && npm --version
RUN npm install --save #ffmpeg-installer/ffmpeg
RUN echo "NPM Modules:" && npm ls
FROM selenium/standalone-chrome
USER root
COPY --from=node_base . .
RUN echo "NPM Modules:" && npm ls
RUN echo "file ends..."

docker network use host mode not working(no port expose)

This is my information:
➜ ~ docker -v
Docker version 19.03.5, build 633a0ea
➜ ~ uname -ar
Darwin Felixs-iMac.local 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov 9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64
when I create a docker with host network mode like this (which is copied from https://docs.docker.com/network/network-tutorial-host/)
docker run --rm -d --network host --name my_nginx nginx
It worked well and I can see the docker is running.
BUT THE PROBLEM IS the port isn't exposed.
when i check with lsof -i:80, there's nothing.
➜ ~ docker run --rm -d --network host --name my_nginx nginx
282fe15a16b70d7bd38b770fd2b67f0023b8fce1f9852a91af4047ef8f6a3f0d
➜ ~ lsof -i:80
➜ ~ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
282fe15a16b7 nginx "nginx -g 'daemon of…" About a minute ago Up About a minute
And i inspected the container, everything seems good:
➜ ~ docker inspect my_nginx
[
{
"Id": "282fe15a16b70d7bd38b770fd2b67f0023b8fce1f9852a91af4047ef8f6a3f0d",
"Created": "2020-02-26T15:35:58.243963941Z",
"Path": "nginx",
"Args": [
"-g",
"daemon off;"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 2238,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-02-26T15:35:58.39452216Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:2073e0bcb60ee98548d313ead5eacbfe16d9054f8800a32bedd859922a99a6e1",
"ResolvConfPath": "/var/lib/docker/containers/282fe15a16b70d7bd38b770fd2b67f0023b8fce1f9852a91af4047ef8f6a3f0d/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/282fe15a16b70d7bd38b770fd2b67f0023b8fce1f9852a91af4047ef8f6a3f0d/hostname",
"HostsPath": "/var/lib/docker/containers/282fe15a16b70d7bd38b770fd2b67f0023b8fce1f9852a91af4047ef8f6a3f0d/hosts",
"LogPath": "/var/lib/docker/containers/282fe15a16b70d7bd38b770fd2b67f0023b8fce1f9852a91af4047ef8f6a3f0d/282fe15a16b70d7bd38b770fd2b67f0023b8fce1f9852a91af4047ef8f6a3f0d-json.log",
"Name": "/my_nginx",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "host",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": true,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"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/062cb6ccb41fb22ba624fb8f93e99e79bcf02cd240fbb4998e47aab1380e015f-init/diff:/var/lib/docker/overlay2/587f9f458f8f0de65434971354636364ff685701fa1f8ba0ba7da4459e22540c/diff:/var/lib/docker/overlay2/1a94586d0949b8305ac14f0934a46149b31db3eb6e7125d7b2965deef318695d/diff:/var/lib/docker/overlay2/ac900d4637ed15f3337e999928ec2a9de2ef4a998f4ce53700a1dffc955d5f0e/diff",
"MergedDir": "/var/lib/docker/overlay2/062cb6ccb41fb22ba624fb8f93e99e79bcf02cd240fbb4998e47aab1380e015f/merged",
"UpperDir": "/var/lib/docker/overlay2/062cb6ccb41fb22ba624fb8f93e99e79bcf02cd240fbb4998e47aab1380e015f/diff",
"WorkDir": "/var/lib/docker/overlay2/062cb6ccb41fb22ba624fb8f93e99e79bcf02cd240fbb4998e47aab1380e015f/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "docker-desktop",
"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",
"NGINX_VERSION=1.17.8",
"NJS_VERSION=0.3.8",
"PKG_RELEASE=1~buster"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"Image": "nginx",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"maintainer": "NGINX Docker Maintainers <docker-maint#nginx.com>"
},
"StopSignal": "SIGTERM"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "be4dc476e331bb8ac857ec069d0aa8383d7700ba5b917c0fed44c59d0b042c99",
"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": "56456bd40ca98647fed01509408599accfadc7cb0f0077ea884b18fc009801b5",
"EndpointID": "e3e870245e2995fbfbae8706fa2daa19f3bf3d59d11d2f8ce2300f2b84b211e0",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
]
Anybody can help me ?
If you're using MacOS, then host network mode will not work on it, the reason for that is that docker-desktop uses an underlying Linux Virtual Machine to run the docker containers, so this host mode is only valid for that VM's network and not for the host(MacOS machine).
Still if you want to access a service running on your host machine(MacOS), from your docker container then you need to use the following hostname in order to connect to that service:
host.docker.internal
You'll be using the above hostname in place of localhost or 127.0.0.1.
For further discussion regarding this you check this github issue

Unable to see the containers in Docker Toolsbox

I have installed docker toolsbox in windows 10.
I have created a container for mysql for the an application using the docker command as given. I'm able to create it and also able to view it using the docker container ls command, but only for the first time.
The Problem occurs when closing the docker toolsbox and reopen it.
When I issued the docker container ls command, I'm unable to find any of the containers what I have created.
But When I tried to inspect the container I'm able to view the container details.
Attached the screenshot and json details of the container.
Please let me know in case of more information needed.
Docker command for creating the MySQL container
docker run --name mysql-docker-petclinic -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=petclinic -e MYSQL_USERNAME=root -e MYSQL_PASSWORD=admin -p 3306:3306 -d mysql:latest
Inspect Command Details
$ docker container inspect mysql-docker-petclinic
[
{
"Id": "f30f66154b7398bbfd1b65d34afc0d973ecdbe62d0e2cbd654003775d11499e0",
"Created": "2018-02-25T16:28:10.327158448Z",
"Path": "docker-entrypoint.sh",
"Args": [
"mysqld"
],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 255,
"Error": "",
"StartedAt": "2018-02-25T16:28:12.428822667Z",
"FinishedAt": "2018-02-26T04:38:54.98958199Z"
},
"Image": "sha256:f0f3956a9dd825e3195f0d1a4fe17cc94b0f6934fc470b09abf8fad87d17ff24",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/f30f66154b7398bbfd1b65d34afc0d973ecdbe62d0e2cbd654003775d11499e0/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/f30f66154b7398bbfd1b65d34afc0d973ecdbe62d0e2cbd654003775d11499e0/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/f30f66154b7398bbfd1b65d34afc0d973ecdbe62d0e2cbd654003775d11499e0/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/f30f66154b7398bbfd1b65d34afc0d973ecdbe62d0e2cbd654003775d11499e0/f30f66154b7398bbfd1b65d34afc0d973ecdbe62d0e2cbd654003775d11499e0-json.log",
"Name": "/mysql-docker-petclinic",
"RestartCount": 0,
"Driver": "aufs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"3306/tcp": [
{
"HostIp": "",
"HostPort": "3306"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
30,
120
],
"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,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": null,
"Name": "aufs"
},
"Mounts": [
{
"Type": "volume",
"Name": "7195ae34c4698fbcdf3737962e799e991e0268a33ea6126af8b0e4aa24b2b18e",
"Source": "/mnt/sda1/var/lib/docker/volumes/7195ae34c4698fbcdf3737962e799e991e0268a33ea6126af8b0e4aa24b2b18e/_data",
"Destination": "/var/lib/mysql",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "f30f66154b73",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"MYSQL_ROOT_PASSWORD=admin",
"MYSQL_DATABASE=petclinic",
"MYSQL_USERNAME=root",
"MYSQL_PASSWORD=admin",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.7",
"MYSQL_MAJOR=5.7",
"MYSQL_VERSION=5.7.21-1debian8"
],
"Cmd": [
"mysqld"
],
"ArgsEscaped": true,
"Image": "mysql:latest",
"Volumes": {
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "0f9a23a942344c2e7c23d425456787db327278dec4601447eb526dfdaa9c3abb",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3306/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "3306"
}
]
},
"SandboxKey": "/var/run/docker/netns/0f9a23a94234",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "*********************************************************",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "*********************************",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "*********************************************************",
"EndpointID": "*********************************************************",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "*********************************************************",
"DriverOpts": null
}
}
}
}
]
Screenshots
1. Docker ls command
2. Docker Inspect Command Details
------------- UPDATE -------------
docker container ls by default shows only the running container.
closing the docker toolsbox and reopen it
That means all your containers are now in "Exited" state.
Try:
docker container ls --all
See also docker ps -a

Resources