Thread
#prefect-server
    p

    Prasanth Kothuri

    10 months ago
    Hello all, I am using prefect docker agent, for the flow run containers I need to expose some ports, how can I do this ? e.g
    -p 12001:12001
    Kevin Kho

    Kevin Kho

    10 months ago
    Hey @Prasanth Kothuri, looking into this
    I guess that would be the best bet. Since the Docker syntax is like:
    client.api.create_host_config(port_bindings={
        12001:12001
    })
    In Prefect it would be like:
    DockerRun(...,host_config={"port_bindings" = {12001:12001}})
    p

    Prasanth Kothuri

    10 months ago
    👍
    @Kevin Kho I am doing the following
    # flow run time configuration
    f.run_config = DockerRun(
        labels=["dt4dev_osdataproc"],
        image="<http://gitlab-registry.internal.sanger.ac.uk/pam-dt4/spark-service/spark-service-docker/spark-app:v0.3|gitlab-registry.internal.sanger.ac.uk/pam-dt4/spark-service/spark-service-docker/spark-app:v0.3>",
        host_config={"port_bindings":{12001:12001}},
        env={"rpc_port": "12001","bm_port": "12101"}
    )
    when I execute the flow I don't see the port mapping on docker ps
    root@dt4-prefect:~/prefect# docker ps
    CONTAINER ID   IMAGE                                                                                             COMMAND                  CREATED          STATUS                 PORTS                            NAMES
    079f58a79463   <http://gitlab-registry.internal.sanger.ac.uk/pam-dt4/spark-service/spark-service-docker/spark-app:v0.3|gitlab-registry.internal.sanger.ac.uk/pam-dt4/spark-service/spark-service-docker/spark-app:v0.3>   "/usr/bin/entrypoint…"   10 seconds ago   Up 9 seconds                                            pearl-tiger
    Kevin Kho

    Kevin Kho

    10 months ago
    Ok I’m not confident this is exposed now. The example here says it can be done without supplying the ports though. (check under port bindings). But in Prefect, the
    ports
    kwarg is not exposed. If what you tried doesn’t work, I think we need to open an issue
    client.api.create_container(
        'busybox', 'ls', ports=[1111, 2222],
        host_config=client.api.create_host_config(port_bindings={
            1111: 4567,
            2222: None
        })
    )
    I’ll open an issue for this
    p

    Prasanth Kothuri

    10 months ago
    ok, thank you, let me see if I use host networking in the meantime like this
    host_config={"network_mode":"host"},
    this should make all the ports reachable ?
    Kevin Kho

    Kevin Kho

    10 months ago
    I guess that would yeah