docker: 无法以主机模式登录容器

docker: 无法以主机模式登录容器

我使用自定义了图像Debian:书呆子。通过模式安装后bridge,我可以在宿主机(Windows 10)上通过SSH登录容器。但是,切换到host模式后,我无法登录。我尝试过Docker0 ip:172.17.0.1,eth0 ip:192.168.65.4,洛伊普:127.0.0.1,但都不起作用。问题是什么?

Docker0 ip 和 lo ip 可以在主机上 ping 通,但是eth0 ip不能。执行service ssh status容器内部显示sshd正在运行。

1,运行失败ssh -v -p 22 [email protected]

   C:\Users\guoya>ssh -v -p 22  [email protected]
    OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
    debug1: Reading configuration data C:\\Users\\guoya/.ssh/config
    debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22.
    debug1: connect to address 127.0.0.1 port 22: Connection refused
    ssh: connect to host 127.0.0.1 port 22: Connection refused

2、安装并启动容器:

   @echo off
    tasklist /FI "IMAGENAME eq docker.exe" | find "docker.exe" > nul
    if %errorlevel% equ 0 (
        echo Docker is running.

    rem Stop and remove containers based on images with repository containing "dobot"
    for /f "tokens=1,2" %%A in ('docker ps -a --format "{{.Image}} {{.Names}}" ^| find "dobot"') do (
        docker stop %%B
        docker rm %%B
    )

    rem Remove images with repository containing "dobot"
    for /f "tokens=*" %%A in ('docker images --format "{{.Repository}}:{{.Tag}}" ^| find "dobot"') do (
        docker rmi %%A -f
    )

    rem Load the Docker image from the tar file in the current directory
    docker load -i "%cd%\images\v4vc.tar"

    rem Run the Docker container
    docker run --dns=8.8.8.8 -d --name=crv4  --net=host dobotv4vc:v450stable_v1
      echo ############################################################
      echo The v450stable_v1 version of the virtual controller has been successfully installed.
      echo ############################################################
) else (
    echo *******************************************
    echo Docker is not running, please run it first.  
    echo *******************************************
)
pause

3、集装箱信息:

# ifconfig 
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:66ff:fe01:def6  prefixlen 64  scopeid 0x20<link>
        ether 02:42:66:01:de:f6  txqueuelen 0  (Ethernet)
        RX packets 187901  bytes 54114300 (51.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 275524  bytes 65536141 (62.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.65.4  netmask 255.255.255.255  broadcast 0.0.0.0
        inet6 fe80::1816:9dff:fe76:1e1  prefixlen 64  scopeid 0x20<link>
        ether 1a:16:9d:76:01:e1  txqueuelen 0  (Ethernet)
        RX packets 249  bytes 55696 (54.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 241  bytes 26463 (25.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 23489  bytes 1229382 (1.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 23489  bytes 1229382 (1.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# service ssh status 
sshd is running.

相关内容