I've got a python docker container that starts in port 8000. This process, after a user interaction, starts, in the same container, the h20 java process in background in the port 54321. 
Both ports are exposed in the Dockerfile:
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
RUN apt update && apt install -y default-jre
EXPOSE 8000
EXPOSE 54321
COPY . /code/
Both ports are mapped in docker-compose.yml:
  backend:
    image: xxxxx/xxx-backend
    build: backend/xxx/.
    ports:
      - "8000:8000"
      - "54321:54321"
    environment:
      - "KEY: value"
    command: python manage.py runserver 0.0.0.0:8000
    depends_on:
      - db
    networks:
      - xxx
The problem is:
When the container runs, port 8000 is mapped, but when I start the h2o server (it's python h2o.init()), the server starts and it's up and running (and it is accesible from lynx inside the container to localhost:54321), but the mapping doesn't work. Seems that 54321 port is not mapped at all because it's not in the CMD or in the startup process.
Is there a solution for map ports even if the process is not started on container startup?
Update
This is my docker-compose ps:
     Name                   Command                State                          Ports                      
-------------------------------------------------------------------------------------------------------------
some_container_1   python manage.py runserver ...   Up         0.0.0.0:54321->54321/tcp, 0.0.0.0:8000->8000/tcp
 
    