Docker Community Forums

Share and learn in the Docker community.

Apache container / ip dont works

Hi! Please help me.

I install docker desktop on a windows 10. a want to start an apache server container. it runs.

docker network inspect sc_docker_patched_sc-test
[
    {
        "Name": "sc_docker_patched_sc-test",
        "Id": "e0770c9aaa2b4e583b4d0f26e383ba011a9c3e720a48246ac79f6bbfc7329b18",
        "Created": "2021-12-03T10:46:05.759946Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.23.0.0/24"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "b5462c645b94a561ae45e2b7b4601d040ea3cf42b0a85dd4f9fc6d596b02c110": {
                "Name": "sc_core-test",
                "EndpointID": "104ba9e4200eab185b1f5d04ddc7c29b9b0cf7136e87c2731b9f94ad2845b605",
                "MacAddress": "02:42:ac:17:00:02",
                "IPv4Address": "172.23.0.2/24",
                "IPv6Address": ""
            },
            "f4fc0ab5674df05d00efc3b5be668b25e4c09f6ef5568dee413edee8be3fb8c2": {
                "Name": "db-test",
                "EndpointID": "b270bc863ad07dfbf13ab91a080c8f1d0e2b3f9a4a405dcfedab45242ed9f433",
                "MacAddress": "02:42:ac:17:00:03",
                "IPv4Address": "172.23.0.3/24",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "sc-test",
            "com.docker.compose.project": "sc_docker_patched",
            "com.docker.compose.version": "1.29.2"
        }
    }
]

the containers are running

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sc_core-test
'172.23.0.2'
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db-test
'172.23.0.3'

but in browser i cant access the ip-s

ping 172.23.0.3

Pinging 172.23.0.3 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 172.23.0.3:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

what is the problem?

Can you please show us how you started the Apache container? Like what ports did you publish using docker run -p?

i have a docker-compose-dev.jml and i do compose up in visual basic code in terminal. This create the images and tha contaners and start it automaticaly.

and after them i have a docker desktop instaled in windows 10. In this docker desktop i stop and start the containers.

version: '3'
services:
 db-test:
   image: db-test
   container_name: db-test
   hostname: db-test
   build:
    context: mariadb
   networks:
    sc-test:
        ipv4_address: 172.23.0.3
   volumes:
     - "dbdata:/var/lib/mysql"
 sqlite-test:
   image: sqlite-test
   hostname: sqlite-test
   build:
    context: sqlite
   volumes:
     - "./sqlite/db:/var/www/runtime"
 sc_core-test:
   image: sc_core_test
   container_name: sc_core-test
   hostname: sc_core-test
   build:
    context: apache
   networks:
    sc-test:
        ipv4_address: 172.23.0.2  
   volumes:
     - "./apache/sc_core:/var/www/html"
     - "mail:/var/www/html/mail"
     - "messages:/var/www/html/messages"
     - "avatar:/var/www/html/web/avatar"
     - "media:/var/www/html/web/media"
networks:
 sc-test:
  driver: bridge
  ipam:
   driver: default
   config:
    - subnet: 172.23.0.0/24
volumes:
        dbdata:
        mail:
        messages:
        avatar:
        media:

I have 2 containers an apache whit port 80/tcp and an sql container whit 3306/tcp .

I don’t know that app, but does that allow you to “publish ports”? Like one would do using docker run -p ... from the command line?

(Please use the editor toolbar to format your post. I’ve fixed it for you now, and removed the empty lines. Beware that whitespace matters in YAML, and your paste may have mangled that.)

This was the command:

docker run --rm -d -p 80:80/tcp sc_core_test:latest

Of course the windows host won’t be able to access a bridged ip of a bridge that only lives in the docker host vm. Though, if exec into the wsl2 distribution or the wsl1 hyper-v vm, you should be perfectly able to reach the container.

Docker provides a dns-based service discovery for container to container communication within the same container network. Then you simply use the service name (and container port) to access a service in another container in the same network. Usualy if users try to enforce ip because it’s a pattern they are used from the vm world, though it’s neither required, nor recommended in the container world - unless there is no other way.