Unable to change port for action server while launching it throught docker

Hello all,

I am unable to resolve this issue for deploying action server to a specific port number while using it through docker. Code is working as intended for the default server, but there is no change in port being used when I launch it for different ports.

Goal: To run action server on a different port via docker.

Current Issue: Even though I am changing the port for action server, it doesn’t reflect when executing.

DockerFile

version: '3.0'
services:
  rasa:
    image: rasa/rasa:1.10.8
    ports:
      - 5006:5006
    volumes:
      - ./rasa:/app
    command:
      - run
      - -m models
      - --enable-api
      - --cors
      - "*"
      - -p 5006
      
  action_server:
    image: rasa/rasa-sdk:1.10.2
    volumes:
      - ./rasa/actions:/app/actions
    ports:
      - 5056:5056

         
  flask:
    container_name: hr_flask2
    restart: always
    build: ./flask_app
    ports: 
      - 7500:7500
    command: gunicorn -w 1 -b 0.0.0.0:7500 wsgi:app
          
  nginx:
    container_name: nginx2
    restart: always
    build: ./nginx
    ports:
      - "65:65"
    depends_on:
      - flask

Endpoints File

action_endpoint:
  url: "http://action_server:5056/webhook"

Nginx File

server {

    listen 65;
    location / {
	    include uwsgi_params;
		uwsgi_pass flask:7500;

    }

}

Flask App file


from flask import Flask  
from flask import render_template
from flask_ngrok import run_with_ngrok
from flask_cors import CORS,cross_origin
# export FLASK_RUN_PORT=5000


# creates a Flask application with name "app"
app = Flask(__name__, static_url_path='/static')
app.config['CORS_HEADERS'] = 'Content-Type'
CORS(app, resources={r"*": {"origins": "*"}})

# run_with_ngrok(app)

# a route to display our html page called "index.html" gotten from [react-chat-widget](https://github.com/mrbot-ai/rasa-webchat)
@app.route("/")
@cross_origin()
def index():  
    return render_template('index.html')

# run the application
if __name__ == "__main__":
 
    app.run(host="0.0.0.0",port="7500",debug=False)
    #app.run(debug=False)

There is no error in terminal when I give docker-compose up command, but this is the result for action server:

action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_validate'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_restart'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_feedback'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_candidate_assesment'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'actions_application_status'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_job_opening'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_select_job_position'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_business_email'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_phoneNumber'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_internal_job_Postings'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_policy_validate'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_policy_number'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_complete_exit_process'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_Upload_Rembursment_Proofs'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_Upload_Rembursment_Proofs_validate'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_leave_balance'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_company_updates'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_more_detail_updates'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_employee_benefits'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_employee_benefits_detail'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_policy_over_mail'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_get_salary_slip'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_grievance_reporting'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_other_complaint'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_upload_document'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_otp'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_employe_feedback'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_main_menu'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_candidate_feedback'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_Learning_Training'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_leave_date'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_job_form'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_employee_boarding'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_default_fallback'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.executor  - Registered function for 'action_default_ask_affirmation'.
action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://localhost:5055

Note: Everything other than the line mentioned below is working as intended.

action_server_1  | 2021-09-06 06:22:13 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://localhost:5055

How do I make it so that the action server is running on the port 5056 instead?

I’m not an expert on Docker, but in the call to the rasa server you have the option “-p 5006”. You need a similar option for the action server. The endpoints file is right, but it only tells the rasa server in which port the action server is running.

@Jainil-Gosalia Strange basically it should work, but do try this below code may be it help. Can you please remove the container / image and again docker-compose up --build and share the docker ps -a for me let check on which port the containers are running. Or if there is no harm let it run on 5055 if you are not using that port.

  action_server:
    image: rasa/rasa-sdk:1.10.2
    volumes:
      - ./rasa/actions:/app/actions
    ports:
      - 5056:5056
 action_server:
    image: rasa/rasa-sdk:1.10.2
    volumes:
      - ./rasa/actions:/app/actions
    ports:
      - 5056:5056
    command:
     - rasa 
     - run
     - actions
     - p 5056

Original Terminal Command without docker container:

rasa run actions -p 5056 --debug

@Jainil-Gosalia can I even request you to please use the latest image for rasa and rasa-sdk

 image: rasa/rasa:latest
 image: rasa/rasa-sdk:latest

@Jainil-Gosalia even you can ref this thread: Dockerizing my rasa chatbot application that has botfront - #11 by nik202

I wish that this will solve your issue and if your problem persist do let me know please. Good Luck!

Hello @Gehova,

Command added to docker-compose file

version: '3.0'
services:
  rasa:
    image: rasa/rasa:1.10.8
    ports:
      - 5006:5006
    volumes:
      - ./rasa:/app
    command:
      - run
      - -m models
      - --enable-api
      - --cors
      - "*"
      - -p 5006
      
  action_server:
    image: rasa/rasa-sdk:1.10.2
    volumes:
      - ./rasa/actions:/app/actions
    ports:
      - 5056:5056
    command:
      - -p 5056

         
  flask:
    container_name: hr_flask2
    restart: always
    build: ./flask_app
    ports: 
      - 7500:7500
    command: gunicorn -w 1 -b 0.0.0.0:7500 wsgi:app
          
  nginx:
    container_name: nginx2
    restart: always
    build: ./nginx
    ports:
      - "65:65"
    depends_on:
      - flask
      

I have tried doing that exact command, but it doesn’t seem to work. This is the output I am currently getting when I add the aforementioned command to docker-compose file.

action_server_1  | Available options:
action_server_1  |  start  - Start Rasa Action Server
action_server_1  |  help   - Print this help
action_server_1  |  run    - Run an arbitrary command inside the container
comphrwithdockeranothercopy_action_server_1 exited with code 0

I have referred to rasa documentation and they don’t give any commands while launching chatbot through docker-compose file.

Link to the documentation I am referring to: Customize Your Deployment

Hey @nik202,

Command:

docker-compose up --build 

This is the output of when I used the aforementioned command.

Output:

Building flask
Step 1/6 : FROM python:3.6
 ---> 4b6c4a2e83f7
Step 2/6 : COPY . /app
 ---> Using cache
 ---> ff4fa75e1d6b
Step 3/6 : WORKDIR /app
 ---> Using cache
 ---> f8cf1f1a5853
Step 4/6 : RUN pip install -r requirements.txt
 ---> Using cache
 ---> 3a1528258482
Step 5/6 : ENTRYPOINT []
 ---> Using cache
 ---> e13170d6f937
Step 6/6 : CMD ["gunicorn", "-b", "0.0.0.0:7500", "wsgi:app"]
 ---> Using cache
 ---> 6834a62da400
Successfully built 6834a62da400
Successfully tagged comphrwithdockeranothercopy_flask:latest
Building nginx
Step 1/3 : FROM nginx
 ---> dd34e67e3371
Step 2/3 : RUN rm /etc/nginx/conf.d/default.conf
 ---> Using cache
 ---> f7f0f569cc50
Step 3/3 : COPY nginx.conf /etc/nginx/conf.d/
 ---> Using cache
 ---> 60aca9defc32
Successfully built 60aca9defc32
Successfully tagged comphrwithdockeranothercopy_nginx:latest
Starting comphrwithdockeranothercopy_action_server_1 ... done
Starting hr_flask2                                   ... done
Starting comphrwithdockeranothercopy_rasa_1          ... done
Starting nginx2                                      ... done
Attaching to hr_flask2, comphrwithdockeranothercopy_action_server_1, comphrwithdockeranothercopy_rasa_1, nginx2
hr_flask2        | [2021-09-07 09:25:41 +0000] [1] [INFO] Starting gunicorn 20.1.0
hr_flask2        | [2021-09-07 09:25:41 +0000] [1] [INFO] Listening at: http://0.0.0.0:7500 (1)
hr_flask2        | [2021-09-07 09:25:41 +0000] [1] [INFO] Using worker: sync
hr_flask2        | [2021-09-07 09:25:41 +0000] [9] [INFO] Booting worker with pid: 9
nginx2           | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx2           | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx2           | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx2           | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
nginx2           | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx2           | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx2           | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: using the "epoll" event method
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: nginx/1.21.1
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: built by gcc 8.3.0 (Debian 8.3.0-6) 
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: OS: Linux 5.11.0-27-generic
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: start worker processes
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: start worker process 23
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: start worker process 24
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: start worker process 25
nginx2           | 2021/09/07 09:25:42 [notice] 1#1: start worker process 26
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_validate'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_restart'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_feedback'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_candidate_assesment'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'actions_application_status'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_job_opening'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_select_job_position'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_business_email'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_phoneNumber'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_internal_job_Postings'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_policy_validate'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_policy_number'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_complete_exit_process'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_Upload_Rembursment_Proofs'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_Upload_Rembursment_Proofs_validate'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_leave_balance'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_company_updates'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_more_detail_updates'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_employee_benefits'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_employee_benefits_detail'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_policy_over_mail'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_get_salary_slip'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_grievance_reporting'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_other_complaint'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_upload_document'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_otp'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_employe_feedback'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_main_menu'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_candidate_feedback'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_Learning_Training'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_leave_date'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_job_form'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_employee_boarding'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_default_fallback'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.executor  - Registered function for 'action_default_ask_affirmation'.
action_server_1  | 2021-09-07 09:25:42 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://localhost:5055
rasa_1           | 2021-09-07 09:25:45 INFO     root  - Starting Rasa server on http://localhost:5006
rasa_1           | 2021-09-07 09:26:01.429856: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: UNKNOWN ERROR (303)
rasa_1           | /opt/venv/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
rasa_1           |   warnings.warn(msg, category=FutureWarning)
rasa_1           | /opt/venv/lib/python3.7/site-packages/rasa/nlu/classifiers/diet_classifier.py:918: FutureWarning: 'EmbeddingIntentClassifier' is deprecated and will be removed in version 2.0. Use 'DIETClassifier' instead.
rasa_1           |   model=model,
rasa_1           | 2021-09-07 09:26:17 INFO     root  - Rasa server is up and running.

For the containers up

sudo docker ps -a
CONTAINER ID   IMAGE                               COMMAND                  CREATED         STATUS              PORTS                                                 NAMES
d5f7227d0f7c   comphrwithdockeranothercopy_nginx   "/docker-entrypoint.…"   3 minutes ago   Up About a minute   0.0.0.0:65->65/tcp, :::65->65/tcp, 80/tcp             nginx2
ec1e746dea61   rasa/rasa:1.10.8-full               "rasa run '-m models…"   3 minutes ago   Up About a minute   5005/tcp, 0.0.0.0:5006->5006/tcp, :::5006->5006/tcp   comphrwithdockeranothercopy_rasa_1
85771d81da51   comphrwithdockeranothercopy_flask   "gunicorn -w 1 -b 0.…"   3 minutes ago   Up About a minute   0.0.0.0:7500->7500/tcp, :::7500->7500/tcp             hr_flask2
83aaed3152cd   rasa/rasa-sdk:1.10.2                "./entrypoint.sh sta…"   3 minutes ago   Up About a minute   5055/tcp, 0.0.0.0:5056->5056/tcp, :::5056->5056/tcp   comphrwithdockeranothercopy_action_server_1

I need action server to run on 5056 instead. We are trying to deploy multiple chatbots on a single server, and so I would need action server to launch on whatever port I choose to.

My chatbot is in version 1.10.8, I am not sure if using latest images would work, but I will give it a shot. Thanks for your help, I will definitely check out the forum post you linked.