Home > Net >  MLRun Docker failed, port is already allocated
MLRun Docker failed, port is already allocated

Time:11-19

I installed MLRun to the docker and I got

Error invoking remote method 'docker-start-container': Error: (HTTP code 500) server error - driver failed programming external connectivity on endpoint desktopdockertools-mlrun-api-1 (a5a67db8a74bf4981d44477ffb77dccb25d2401d8fdd95c64262de30ed6d1a56): Bind for 0.0.0.0:8080 failed: port is already allocated

Do you have any experience?

I installed different MLRun versions with Jupyter (usage compose.with-jupyter.yaml) and without Jupyter (compose.yaml), but I still see the same issue. I made installation based on https://docs.mlrun.org/en/latest/install/local-docker.html#install-local-docker.

CodePudding user response:

This error is telling you, that you are running another service (application) on localhost (probably your computer) with port 8080.

So basically you have two options on how to solve this problem:

  1. run MLRun Docker instance on different port
  2. find and stop the running application and then run the MLRun Docker instance

Solution for case 1.:

You have to change setting in Docker compose.yaml. file, like this:

services:
  mlrun-api:
    image: "mlrun/mlrun-api:${TAG:-1.0.6}"
    ports:
      - "8180:8080"
    environment:
      MLRUN_ARTIFACT_PATH: "${SHARED_DIR}/{{project}}"
      # using local storage, meaning files / artifacts are stored locally, so we want to allow access to them
      MLRUN_HTTPDB__REAL_PATH: /data
      MLRUN_HTTPDB__DATA_VOLUME: "${SHARED_DIR}"
      MLRUN_LOG_LEVEL: DEBUG
      MLRUN_NUCLIO_DASHBOARD_URL: http://nuclio:8070
      MLRUN_HTTPDB__DSN: "sqlite:////data/mlrun.db?check_same_thread=false"
      MLRUN_UI__URL: http://localhost:8060
      # not running on k8s meaning no need to store secrets
      MLRUN_SECRET_STORES__KUBERNETES__AUTO_ADD_PROJECT_SECRETS: "false"
      # let mlrun control nuclio resources
      MLRUN_HTTPDB__PROJECTS__FOLLOWERS: "nuclio"
    volumes:
      - "${SHARED_DIR:?err}:/data"
    networks:
      - mlrun

  mlrun-ui:
    image: "mlrun/mlrun-ui:${TAG:-1.0.6}"
    ports:
      - "8060:8090"
    environment:
      MLRUN_API_PROXY_URL: http://mlrun-api:8080
      MLRUN_NUCLIO_MODE: enable
      MLRUN_NUCLIO_API_URL: http://nuclio:8070
      MLRUN_NUCLIO_UI_URL: http://localhost:8070
    networks:
      - mlrun

  nuclio:
    image: "quay.io/nuclio/dashboard:${NUCLIO_TAG:-stable-amd64}"
    ports:
      - "8070:8070"
    environment:
      NUCLIO_DASHBOARD_EXTERNAL_IP_ADDRESSES: "${HOST_IP:-127.0.0.1}"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - mlrun

networks:
  mlrun: {}

Solution for case 2.:

This case require some investigation, I recommend you to try to look for some other Docker containers with command docker ps -a where you can see other containers and their used ports. If you will find some containers using the same port 8080, you should stop and delete them with command docker stop <container_id / container_name>; docker rm <container_id / container_name> and then run MLRun container

In case you don't see any other container running on port 8080, you have to find the service (application) by using commands like:

# for unix like systems
# if you are using Windows, try to find the similar one command

netstat -ltnp | grep -w ':8080' 
lsof -i :8080

After you find the process of the service running on port 8080, you can kill the process with command kill <PROCESS_ID> and then run MLRun container.

CodePudding user response:

It happened based on more MLRun installations, where first installation allocated requested port 8080 and other installations failed. The work-arround is:

  • delete container from docker
  • do new installation

If you need to use more MLRuns (e.g. with jupyter and without jupyter), you have to change ports in YAML files.

  • Related