相关疑难解决方法(0)

从docker容器访问主机的ssh隧道

使用ubuntu tusty,有一个服务在远程机器上运行,我可以通过ssh隧道从端口转发访问localhost:9999.

我有一个docker容器正在运行.我需要通过主机的隧道从容器内访问该远程服务.

我尝试从容器隧道到主机-L 9000:host-ip:9999,然后127.0.0.1:9000从容器内访问服务无法连接.为了检查端口映射是否打开,我试过了 nc -luv -p 9999 # at host nc -luv -p 9000 # at container

此之后,parag.2但即使 nc -luv host-ip -p 9000 在集装箱内进行操作也没有感知到的沟通

我也试过通过映射端口docker run -p 9999:9000,但是这报告绑定失败,因为主机端口已经在使用中(可能是从主机隧道到远程机器).

所以我的问题是

1 - 如何实现连接?我是否需要设置到主机的ssh隧道,或者这可以通过单独的docker端口映射来实现?

2 - 测试连接是什么的快速方法是什么?通过bash,最好是.

谢谢.

ssh bash netcat ssh-tunnel docker

32
推荐指数
4
解决办法
2万
查看次数

什么是linux相当于"docker.for.mac.host.internal"

在Mac和Windows上,可以在容器内使用docker.for.mac.host.internal(替换docker.for.mac.localhost)和docker.for.win.host.internal(替换docker.for.win.localhost).

是否有一个Linux将开箱即用而不传递env变量.

docker docker-for-windows docker-for-mac docker-desktop

22
推荐指数
10
解决办法
2万
查看次数

我的防火墙阻止了从docker容器到外部的网络连接

对我来说,这是一个非常标准的设置,我有一台ubuntu机器运行docker和ufw作为我的防火墙.

如果我的防火墙启用,则docker实例无法连接到外部

$ docker run -i -t ubuntu /bin/bash
WARNING:  Docker detected local DNS server on resolv.conf. Using default external servers: [8.8.8.8 8.8.4.4]
root@d300c5f17207:/# apt-get update
Err http://archive.ubuntu.com precise InRelease
0% [Connecting to archive.ubuntu.com]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/InRelease  
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/Release.gpg  Temporary failure resolving 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Run Code Online (Sandbox Code Playgroud)

这是ufw日志,显示来自docker容器的阻塞连接.

$ sudo tail /var/log/ufw.log
Jun 30 15:41:56 localhost kernel: [61609.503199] [UFW BLOCK] IN=testbr0 OUT=eth0 PHYSIN=veth8Rj8Nh …
Run Code Online (Sandbox Code Playgroud)

firewall docker

11
推荐指数
3
解决办法
2万
查看次数

使用 vs 代码反应原生 docker 容器以发布到主机操作系统上的 android 模拟器

我正在尝试在 vs 代码上运行一个 react native docker 容器。我能够运行我的代码。但是,容器无法检测到在我的主机上运行的 android 模拟器。

I followed along in this tutorial course:

https://code.visualstudio.com/docs/remote/containers & https://github.com/microsoft/vscode-react-native

正在运行

npx react-native run-android 但是,我收到一条错误消息,指出我的模拟器没有运行。错误 无法安装应用程序。确保您有一个正在运行的 Android 模拟器或已连接的设备。使用 --verbose 标志运行 CLI 以获取更多详细信息。错误:命令失败:./gradlew app:installDebug -PreactNativeDevServerPort=8081

我的 devcontainer.json:-

{
    "name": "React Native Android Container",
  
    // Sets the run context to one level up instead of the .devcontainer folder.
    "context": "..",
  
    // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
    "dockerFile": "Dockerfile",
  
    "runArgs": [
        "--privileged", // give all capabilities to …
Run Code Online (Sandbox Code Playgroud)

android docker react-native

7
推荐指数
1
解决办法
554
查看次数

码头工人。从主机发送邮件

我可以使用邮件从主机发送邮件:

mail -s "Hooray" smb@example.com < /dev/null
Run Code Online (Sandbox Code Playgroud)

但我想使用主机服务器从 docker 容器发送邮件。当我尝试在运行命令中将其映射到 25 端口时,Docker 说“端口已在使用中”:

run -ti -p 25:25 container
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现目标?主机为 Centos,docker 使用 Ubuntu。

ubuntu centos docker

5
推荐指数
1
解决办法
4412
查看次数