After migrating container to service: how to access it?

Hi,
first of all – I’m a docker newbie, so please excuse if this question seems silly.

I started docker by using a Dockerfile and configured it so that it installs my required application server

FROM lucee/lucee52:latest
RUN set -x && \
    apt-get update && \
    apt-get install --no-install-recommends --no-install-suggests -y \
        supervisor \
        && apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
.....
EXPOSE 8888
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]

This all works fine after docker build and docker run.

Because I want to use secrets, I’ve found out that I need to use docker swarm and docker service.

So I “converted” (is this the right term?) my image and pushed it into my local repository - also seems to work fine (image name = test1).

Then I created the service using:

fritz$ docker service create --name servicetest1 --with-registry-auth --publish 8888:8888 --replicas 3 localhost:5000/test1

ulkb7lqkbjqnzzyd9z7fsagq0
overall progress: 3 out of 3 tasks 
1/3: running   [==================================================>] 
2/3: running   [==================================================>] 
3/3: running   [==================================================>] 
verify: Service converged 
Fritzs-MacBook-Pro:registry fritz$ docker container ls
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                    NAMES
44caf0954aab        localhost:5000/test1:latest   "supervisord -c /etc…"   18 seconds ago      Up 16 seconds       8080/tcp, 8888/tcp       servicetest1.1.ondxw6ufprllzdjcvhuwy9i7o
df45b54b5186        localhost:5000/test1:latest   "supervisord -c /etc…"   18 seconds ago      Up 16 seconds       8080/tcp, 8888/tcp       servicetest1.2.nfou6loyd3pymwaml41rwaza1
b6c930e45bc5        localhost:5000/test1:latest   "supervisord -c /etc…"   18 seconds ago      Up 16 seconds       8080/tcp, 8888/tcp       servicetest1.3.xc2js73sy4w6mou3toqtm7vjr
e36686a4ad12        registry:2                    "/entrypoint.sh /etc…"   23 minutes ago      Up 8 minutes        0.0.0.0:5000->5000/tcp   registry

If I look into the logs:

docker service logs servicetest1
servicetest1.3.xc2js73sy4w6@linuxkit-025000000001    | 2018-09-01 22:44:38,556 CRIT Supervisor running as root (no user in config file)
servicetest1.1.ondxw6ufprll@linuxkit-025000000001    | 2018-09-01 22:44:38,715 CRIT Supervisor running as root (no user in config file)
servicetest1.2.nfou6loyd3py@linuxkit-025000000001    | 2018-09-01 22:44:38,737 CRIT Supervisor running as root (no user in config file)
servicetest1.2.nfou6loyd3py@linuxkit-025000000001    | 2018-09-01 22:44:38,737 INFO Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
servicetest1.3.xc2js73sy4w6@linuxkit-025000000001    | 2018-09-01 22:44:38,557 INFO Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
servicetest1.1.ondxw6ufprll@linuxkit-025000000001    | 2018-09-01 22:44:38,715 INFO Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
servicetest1.2.nfou6loyd3py@linuxkit-025000000001    | 2018-09-01 22:44:38,746 INFO RPC interface 'supervisor' initialized
servicetest1.1.ondxw6ufprll@linuxkit-025000000001    | 2018-09-01 22:44:38,724 INFO RPC interface 'supervisor' initialized
servicetest1.3.xc2js73sy4w6@linuxkit-025000000001    | 2018-09-01 22:44:38,570 INFO RPC interface 'supervisor' initialized

it also looks good.

Where I am completely lost is: how to I access the service now?

With the “old” container: I could just go to: localhost:8888 in my browser.

That does not work anymore now.
How can I “reach” the services?

What I understood (and I think I did not yet fully understand) is, that there is a built-in load balancer now available (because of --replicas 3) for the 3 running services.
So, can I reach them individually somehow or is there one entry point and it is non-deterministic how to reach them.

This might be a very simple question, but even after hours (!) of investigation, it seems that I’m missing the single little piece that’s missing here.

Thanks for your help,

Cheers
Fritz

Hi :slight_smile:

No you cant access them individually.
You need to access it, by the host the service is running on, and also using the port you defined in -p (8888)