How to run multiple apps under same port w/ docker lucee?

Hi,

Say, I use
docker build -t app1 .
to build my first app and run it at port 8888 as follows:
docker run -d --rm -p 8888:8888 --name testimage -v /home/userme/lucee/www:/var/www lucee/lucee4
And a few days later, I have another app, so, I build the second app below:
docker build -t app2 .
And I’d like to use the same port of 8888 for app2 as well.
If I simply run it as:
docker run -d --rm -p 8888:8888 --name testimage2 -v /home/userme/lucee/www:/var/www lucee/lucee4 I would get port being used error. So, how do we refine the run command here?

Many thanks.

The -p command maps a host port to the container port, so in that scenario you’d have a port conflict as app1 is still running mapped to 8888. Unless you’ve already stopped app1.

What we do here, for dev anyway, is run the various containers on unique ports and use an nginx container running on 80/443, which in turn talks to the machine names thought 8888…

Within theory, we can run our environment without exposing the lucee ports as we don’t ever talk directly with them…

Thanks for the idea. I tried to change port to 8800:8800 (docker port mapping to tcp port), but unable to run the lucee server side script. Could it be that my cloud service provider block it? But if so why leave port 8888 open (it’s not the standard port, 80)?

Have you changed the port that lucee is listening on?

If not you probably want something like 8800:8888 which tells docker to map port 8800 on the host to 8888 in the container…

1 Like

Right. When you set -p aaaa:bbbb then port aaaa is on the host and port bbbb is inside the Docker container. If the container exposes 8888 for bbbb then that must be used. So this:

Would not work because the container exposes 8888 and not 8800.

But this will work:

1 Like

ok, thanks.

A new issue is that the lucee docker image seems to be using an old app created or “burn” into the lucee/lucee4. Though I’ve done
docker rmi -f oldapp
then
build
run newapp
but they didn’t seem to help. what gives?

Many thanks.