apocas / dockerode-compose

docker-compose in Node.js using dockerode
Apache License 2.0
143 stars 31 forks source link

Ports are not accessible #11

Closed rkesters closed 2 years ago

rkesters commented 3 years ago

When using the below compose file, the service is not reachable on the defined port. However when I use docker-compose the service is reachable.

version: '3'
services:
    wiremock:
        image: 'holomekc/wiremock-gui:latest'
        container_name: my_wiremock
        ports:
            - '8088:8080'
        volumes:
            - 'wmdata:/home/wiremock/storage'
        environment:
            WIREMOCK_OPTIONS: '--max-request-journal=1000,--local-response-templating,--root-dir=/home/wiremock/storage'

Any thoughts, to why.

Alystrasz commented 3 years ago

I confirm I can reproduce what seems to be the same issue with this configuration:

version: '2'
services:
  gost-db:
    image: geodan/gost-db
    volumes:
      - postgis:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: gost
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres

  gost:
    image: geodan/gost
    volumes:
      - gost_conf:/gostserver/config
    depends_on:
      - gost-db
    environment:
      GOST_LOG_VERBOSE_FLAG: 1
      GOST_DB_HOST: gost-db
      GOST_SERVER_EXTERNAL_URI: "http://localhost:8080"

  dashboard:
    image: geodan/gost-dashboard
    ports:
      - "8080:8080"
    depends_on:
      - gost

volumes:
  postgis: {}
  gost_conf: {}

1. Via package

const compose = new DockerodeCompose(docker, 'test/test-compose.yml', 'test');
# docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED         STATUS         PORTS      NAMES
c60e16ca78d7   geodan/gost-dashboard   "/etc/nginx/docker-e…"   3 seconds ago   Up 3 seconds   80/tcp     test_dashboard
b9a56b054876   geodan/gost             "/bin/sh -c ./gost"      4 seconds ago   Up 3 seconds   8080/tcp   test_gost
a5218632ba80   geodan/gost-db          "docker-entrypoint.s…"   4 seconds ago   Up 4 seconds   5432/tcp   test_gost-db

2. Via docker-compose

$ docker-compose -f test/test-compose.yml up
# docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED       STATUS          PORTS                            NAMES
114e8447c9df   geodan/gost-dashboard   "/etc/nginx/docker-e…"   2 hours ago   Up 9 seconds    80/tcp, 0.0.0.0:8080->8080/tcp   test_dashboard_1
b0f65797069f   geodan/gost             "/bin/sh -c ./gost"      2 hours ago   Up 9 seconds    8080/tcp                         test_gost_1
739fb51c2df6   geodan/gost-db          "docker-entrypoint.s…"   5 hours ago   Up 10 seconds   5432/tcp                         test_gost-db_1

We can see here that the 8080 port is correctly exposed by docker-compose, but not by dockerode.

nunokisc commented 3 years ago

Hi, If you add expose tag(see below) you can solve the "problem", we'll check the docker-compose approaches in this case, because, on our example(var compose = new DockerodeCompose(docker, './test/wordpress.yml', 'wordpress');) the port is correctly exposed.

ex: expose:

Alystrasz commented 3 years ago

I confirm the expose tweak works in my case. Thanks!

rkesters commented 3 years ago

I confirm the expose tweak works in my case. Thanks!

garrylachman commented 1 year ago

expose not works for mapping and the regular ports not works