1
I want to be able to access/view my applications through the browser using Docker. I installed Docker for Windows, did not make any additional configuration, and created the files below, along with the following tests.
I got into the container, > php artisan serve
, resulting in:
Laravel Development server Started: http://127.0.0.1:8000
With the application running, I opened another terminal and ran the code curl http://127.0.0.1:8000
, he returned me the initial page of the project without problems.
I tried to access via Google Chrome, localhost:8000, got error
This page isn’t working localhost didn’t send any data. ERR_EMPTY_RESPONSE
With the container running, I ran the command docker ps
to see the doors, result: 0.0.0.0:8000->8000/tcp, 0.0.0.0:8888->80/tcp, 0.0.0.0:80->8000/tcp, 0.0.0.0:8080->8000/tcp php-api-container
I tried to see the IP of the Docker-machine, but there is no.
I tried using the Internet Virtual Switch IP, the error continues.
I tried to access by all ips, which were shown on my machine ipconfig.
Root of the Project
- /grimorie-api (Basic Laravel Installation)
- Docker-Compose.yml
- php. Dockerfile
Docker-Compose.yml
version: "3.7"
services:
php-api:
build:
context: .
dockerfile: php.Dockerfile
container_name: php-api-container
stdin_open: true
tty: true
ports:
- "80:8000"
- "8888:80"
- "8080:8000"
- "8000:8000"
volumes:
- "./grimorie-api:/var/www/html"
php. Dockerfile
FROM php:zts-alpine3.9
RUN apk update && apk upgrade && apk add bash
WORKDIR /var/www/html
Running the Inspect command I have this Json file
{
"Id": "a5e1bffea33aa83e9705d5c9cfe2de000c979c79c8fa8718a9e3c481d97bb77e",
"Created": "2019-10-10T00:31:54.7573076Z",
"Path": "docker-php-entrypoint",
"Args": [
"php",
"-a"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 6090,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-10-10T00:31:57.1874848Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:8fb36fdc3172ae81cede1198b65d99830d30f056d4b0e3500f166d029cf9d5ba",
"ResolvConfPath": "/var/lib/docker/containers/a5e1bffea33aa83e9705d5c9cfe2de000c979c79c8fa8718a9e3c481d97bb77e/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/a5e1bffea33aa83e9705d5c9cfe2de000c979c79c8fa8718a9e3c481d97bb77e/hostname",
"HostsPath": "/var/lib/docker/containers/a5e1bffea33aa83e9705d5c9cfe2de000c979c79c8fa8718a9e3c481d97bb77e/hosts",
"LogPath": "/var/lib/docker/containers/a5e1bffea33aa83e9705d5c9cfe2de000c979c79c8fa8718a9e3c481d97bb77e/a5e1bffea33aa83e9705d5c9cfe2de000c979c79c8fa8718a9e3c481d97bb77e-json.log",
"Name": "/php-api-container",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": [
"61110b176cdcbdc5f84b3d10ddd4b236f781d7e45ecdfed7603452feb17e2703",
"d90937a8115d3b5bce051f096612548a3ded8cd773d8f574f716f3d0f55431bf"
],
"HostConfig": {
"Binds": [
"/host_mnt/c/xampp/htdocs/Grimorie-site/grimorie-api:/var/www/html:rw"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "grimorie-site_default",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "8888"
}
],
"8000/tcp": [
{
"HostIp": "",
"HostPort": "80"
},
{
"HostIp": "",
"HostPort": "8080"
},
{
"HostIp": "",
"HostPort": "8000"
}
]
},
"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": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"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/26b100adb294a905332e18963f4d088298432fffcc62144f0539585a3512b066-init/diff:/var/lib/docker/overlay2/9db1246a8eba275d364a77511da820b0a36cb41ee348b2fad57d92a4990cc4ba/diff:/var/lib/docker/overlay2/a532560303cb9b2af43284da591f4da55c31035786d6b368f26a227f0f0b6473/diff:/var/lib/docker/overlay2/d92f6af3d8d4d02eb10d8b9e4c9619f8343d19bbda1cfc54517a4952a5f61a47/diff:/var/lib/docker/overlay2/f83e012fd9bbba2c732a37930babf9a9418fd85af244dc719dd4952c98f1cb03/diff:/var/lib/docker/overlay2/ceb80ca2adde5a74b9c872088fca714eedad67c737cb9568cacfbabb894976ad/diff:/var/lib/docker/overlay2/302a758ac346f5553059dc49006f0dc78bd32d0161b0a9a200e0a16938c92d30/diff:/var/lib/docker/overlay2/5bb275316d4a2f5395bc83991126924c6a445baad5ff85734b11fb63120f3d99/diff:/var/lib/docker/overlay2/5e3ff034bc4ed73b37b4d0be7663a1dddc9b183bcf3cf85d11a8fd54fa84d703/diff:/var/lib/docker/overlay2/04cd766ee6448c51a9baba6f2df3a11eb7983397fb59250143ff2756c8729341/diff:/var/lib/docker/overlay2/4a11363a75a829ef43f6117f1cd70ade70a0a2841cc33b46945605c1202e68f0/diff",
"MergedDir": "/var/lib/docker/overlay2/26b100adb294a905332e18963f4d088298432fffcc62144f0539585a3512b066/merged",
"UpperDir": "/var/lib/docker/overlay2/26b100adb294a905332e18963f4d088298432fffcc62144f0539585a3512b066/diff",
"WorkDir": "/var/lib/docker/overlay2/26b100adb294a905332e18963f4d088298432fffcc62144f0539585a3512b066/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/host_mnt/c/xampp/htdocs/Grimorie-site/grimorie-api",
"Destination": "/var/www/html",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "a5e1bffea33a",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {},
"8000/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"PHPIZE_DEPS=autoconf \t\tdpkg-dev dpkg \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkgconf \t\tre2c",
"PHP_INI_DIR=/usr/local/etc/php",
"PHP_EXTRA_CONFIGURE_ARGS=--enable-maintainer-zts --disable-cgi",
"PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2",
"PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2",
"PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie",
"GPG_KEYS=CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D",
"PHP_VERSION=7.3.10",
"PHP_URL=https://www.php.net/get/php-7.3.10.tar.xz/from/this/mirror",
"PHP_ASC_URL=https://www.php.net/get/php-7.3.10.tar.xz.asc/from/this/mirror",
"PHP_SHA256=42f00a15419e05771734b7159c8d39d639b8a5a6770413adfa2615f6f923d906",
"PHP_MD5="
],
"Cmd": [
"php",
"-a"
],
"Image": "grimorie-site_php-api",
"Volumes": {
"/var/www/html": {}
},
"WorkingDir": "/var/www/html",
"Entrypoint": [
"docker-php-entrypoint"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "21f96b90be62927618278538cd112333bc092bcf0333b520d5f42647636e65c1",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "grimorie-site",
"com.docker.compose.service": "php-api",
"com.docker.compose.version": "1.24.1"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "cdfa0cf4147241dac3192a7d12e106fc1dc28938cd6495a6fb012db7c79f46b9",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8888"
}
],
"8000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8000"
},
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
},
{
"HostIp": "0.0.0.0",
"HostPort": "80"
}
]
},
"SandboxKey": "/var/run/docker/netns/cdfa0cf41472",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"grimorie-site_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"php-api",
"a5e1bffea33a"
],
"NetworkID": "1a1018c125882ea2e77294a844e75d5bbd4035c0468c5855d9d0051c5c9123aa",
"EndpointID": "e6376ef120e65297bc3937db7730e7804741f09f0d9c4c7c8dd40dc32adc550c",
"Gateway": "172.19.0.1",
"IPAddress": "172.19.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:13:00:02",
"DriverOpts": null
}
}
}
}
Kaue, did you ever run this in linux? It seems to me to be an Issue of Docker for windows itself, something like this https://github.com/docker/for-win/issues/197
– Tuxpilgrim
Another thing, instead of entering the container, specify this in your Dockerfile, with CMD or ENTRYPOINT...
– Tuxpilgrim
When you say Docker for windows, it’s the Desktop or Toolbox?
– gmsantos
Docker Desktop for Windows Link: https://www.docker.com/products/docker-desktop
– Kaue Alves
@Tuxpilgrim not tested on linux yet, I have to run Docker in a windows environment unfortunately.
– Kaue Alves
I know what Kaue looks like (:p), have you seen this Volume I sent? You can run the test directly on dockerfile’s ENTRYPOINT, and see if something changes.
– Tuxpilgrim