Skip to content

Commit 10454f1

Browse files
committed
Add host function to get docker host
1 parent 1e4fa30 commit 10454f1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

testcontainers/core/docker_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1111
# License for the specific language governing permissions and limitations
1212
# under the License.
13+
import urllib
1314
import docker
1415
from docker.models.containers import Container
1516

@@ -41,4 +42,11 @@ def port(self, container_id, port):
4142

4243
def bridge_ip(self, container_id):
4344
container = self.client.api.containers(filters={'id': container_id})[0]
45+
print(container['NetworkSettings']['Networks']['bridge'])
4446
return container['NetworkSettings']['Networks']['bridge']['IPAddress']
47+
48+
def host(self):
49+
try:
50+
return urllib.parse.urlparse(self.client.api.base_url)
51+
except ValueError:
52+
return None

0 commit comments

Comments
 (0)