title: How do you assign IP to WSL2 and/or Docker container so it can be accessed from local network
body: <p>I have a host machine (192.168.1.5) which is running Windows 10 with WSL2 (winver 2004 OS build 19041.329).</p>
  <p>I've moved my Docker script over to WSL2 (runs fine on a Linux vm) and I have that running fine. I just can not access mssql from either the host machine or anything on my local network.</p>
  <p>This is my create script</p>
  <pre><code>sudo docker run -d \
  -p 7000:1433 \
  -e SA_PASSWORD=&lt;hidden&gt; \
  -e ACCEPT_EULA=Y \
  -e MSSQL_PID=Developer \
  -v /home/docker/mssql/backup:/data \
  -v /home/docker/mssql:/var/opt/mssql \
  -e attach_dbs=&quot;[{'dbName':'THEDB','dbFiles':['/data/thedb.mdf','/data/thedb_log. ldf']}]&quot; \
  --name sql microsoft/mssql-server-linux:latest \
  </code></pre>
  <p>It works and I can connect into it and query etc from within the image.</p>
  <p>I have tried various --network options such as host and bridge.
  I'm unsure if this is a docker issue or a WSL2 issue, although I've done a WSL2 sudo apt update fine. I think it uses nat to access the Internet for that. It can't ping any machines on the network. (from WSL2)</p>
  <p>How do I configure a public IP (ipv4) such that I can access the mssql database remotely.</p>