Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Ports in Docker? #345

Open
nateybear opened this issue Jun 25, 2024 · 0 comments
Open

Dynamic Ports in Docker? #345

nateybear opened this issue Jun 25, 2024 · 0 comments

Comments

@nateybear
Copy link

I'm on a Mac, running a SQL Server database via Docker. When I try to connect and execute queries via sqlcmd, I am able to. However, tiberius is not working for me. It appears that SQL Server is allocating a dynamic port for some reason. I guess my questions are:

  1. Why is the tiberius connection being given a dynamic port when sqlcmd isn't? This isn't a named instance, which afaik is what triggers mssql to allocate a dynamic port.
  2. Is there a workaround? I only see options for using SCM to turn off dynamic ports. I can't find any configuration via env vars or the mssql command that can turn it off. I would prefer not to forward all of my ports to the docker container, if possible.

Any advice is very much appreciated 🙂

Repro:

use tiberius::Config;
use tokio::net::TcpStream;
use tokio_util::compat::TokioAsyncWriteCompatExt;

#[tokio::main]
async fn main() -> Result<()> {
    let tcp = TcpStream::connect(Config::new().get_addr()).await?;
    println!("{:?}", tcp);
    Ok(())
}

Outputs:
PollEvented { io: Some(TcpStream { addr: [::1]:61434, peer: [::1]:1433, fd: 11 }) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant