You can ping outside from centOS
[root @ 7971df01d10c /] # ping google.com PING google.com (188.8.131.52) 56 (84) bytes of data. 64 bytes from nrt12s23-in-f14.1e100.net (184.108.40.206): icmp_seq = 1 ttl = 37 time = 36.2 ms 64 bytes from nrt12s23-in-f14.1e100.net (220.127.116.11): icmp_seq = 2 ttl = 37 time = 59.0 ms 64 bytes from nrt12s23-in-f14.1e100.net (18.104.22.168): icmp_seq = 3 ttl = 37 time = 29.0 ms 64 bytes from nrt12s23-in-f14.1e100.net (22.214.171.124): icmp_seq = 4 ttl = 37 time = 717 ms 64 bytes from nrt12s23-in-f14.1e100.net (126.96.36.199): icmp_seq = 5 ttl = 37 time = 60.6 ms
You can also ping locally
[root @ 7971df01d10c /] # ping 172.17.0.2 PING 172.17.0.2 (172.17.0.2) 56 (84) bytes of data. 64 bytes from 172.17.0.2: icmp_seq = 1 ttl = 64 time = 0.043 ms 64 bytes from 172.17.0.2: icmp_seq = 2 ttl = 64 time = 0.062 ms 64 bytes from 172.17.0.2: icmp_seq = 3 ttl = 64 time = 0.062 ms 64 bytes from 172.17.0.2: icmp_seq = 4 ttl = 64 time = 0.042 ms 64 bytes from 172.17.0.2: icmp_seq = 5 ttl = 64 time = 0.062 ms 64 bytes from 172.17.0.2: icmp_seq = 6 ttl = 64 time = 0.063 ms
It looks like this when you hit ip a
[root @ 7971df01d10c /] # ip a 1: lo:<LOOPBACK, UP, LOWER_UP>mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00: 00: 00: 00: 00: 00 brd 00: 00: 00: 00: 00: 00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: tunl0 @ NONE:<NOARP>mtu 1480 qdisc noop state DOWN group default qlen 1 link/ipip 0.0.0.0 brd 0.0.0.0 3: ip6tnl0 @ NONE:<NOARP>mtu 1452 qdisc noop state DOWN group default qlen 1 link/tunnel6 :: brd :: 6: eth0 @ if7:<BROADCAST, MULTICAST, UP, LOWER_UP>mtu 1500 qdisc noqueue state UP group default link/ether 02: 42: ac: 11: 00: 02 brd ff: ff: ff: ff: ff: ff link-netnsid 0 inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0 valid_lft forever preferred_lft forever
When you try to connect ssh from outside, it looks like this
ssh: connect to host 172.17.0.2 port 22: Network is unreachable
Ping from outside
ping 172.17.0.2 PING 172.17.0.2 (172.17.0.2): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 36 bytes from 188.8.131.52: Destination Host Unreachable Vr HL TOS Len ID Flg off TTL Pro cks Src Dst 4 5 00 5400 46e1 0 0000 3c 01 7c24 10.13.204.27 172.17.0.2
Answer # 1
When connecting from the host to the container, the port will be forwarded, so the destination IP should be 127.0.0.1 instead of 172.17.0.2.
I tried to build a development environment with Docker for Mac. did. Another reason is that the IP address was not set with the "nmtui" command.
In the first place, the purpose of SSH connection was that it was necessary to create one server as a team.
I'm sorry for the delay. The question became unclear when I was a beginner of server construction and I didn't know what to do. I'm sorry for the inconvenience to the respondents. Thank you for your answer.
Answer # 2
Hmm, where should I explain?
Assumes that the following conditions are met:
184.108.40.206 is the host OS address where Docker is running.
You can log in to 220.127.116.11 from the Internet side with ssh.
Ssh is set appropriately on the Docker side (running or key pair is set properly)Raise Docker with port fowarding enabled
First, start SSH (TCP/21) running on the Docker container to port forward to an appropriate port of the host OS (eg TCP/7021).
Create an ssh tunnel from the Internet environment to 18.104.22.168
$docker run --name hogehoge -d -p 7021: 21 containar_name
For the tunnel just created ssh
$ssh -L 9999: localhost: 7021 22.214.171.124
$ssh -p 9999 localhost
There is no relationship between ping and ssh.
Please read appropriately per address.
Since 172.17.0.2 is a private address, it has no meaning outside the LAN.
Hmm, Docker is not related at all.
- i cannot connect to linux (centos7) installed on virtulbox from the host machine by ssh
- can't connect to mysql launched by docker
- linux - how to display and arrange the docker icon on centos8 desktop?
- How to connect linux using paramiko module
- linux - [docker] after creating a debian container, it is not displayed by ls
- i want to connect to mysql from the app inside the docker container
- kubernetes on docker desktop (win) wants to connect to localhost of host machine from pod
- linux - i want to install docker but i don't have administrator privileges
- linux - please tell me what happens if docker is installed in this system
- linux - when connecting different nws to multiple nics with centos7, is it correct to set the gateway for each nic?
- linux - i want to count up variables in a centos7 shell script
- linux - i want to use a hyphen as a character string in centos7 shell script
- linux - failed to open port on centos7
- Linux (CentOS7) tutorial for installing mysql 8011 using RPM
- linux - i installed centos8 on vmware but can't connect to the external network
- linux - change docker toolbox permissions
- Linux system (CentOS7 installation) tutorial for installing JDK8
- Tutorial to connect remote docker using portainer
- linux - can't find docker command
- CentOS7 deploys version 19 docker (simple, you can follow)
- linux - i am unable to log in for the first time after launching a new os
- linux - i want to boot centos 8 using virtualbox
- error in php bin/console server:run
- linux - i want to introduce phpmyadmin with sakura vps
- sqlite - vuls was built with podman (docker compatible) with centos8, but the vulnerability information database cannot be updat
- linux - [centos 7] after starting the ftp server with centos, i cannot log in to the ftp server using the windows command prompt
- linux - [centos8] i installed the xen rpm file how can i import this into centos?
- linux - [centos8] i would like to know how to install the minimal guest os
- linux - [centos 8] xen cannot be installed
- linux grep "no such file or directory" message meaningless