Home > OS >  What do the docker container how external access
What do the docker container how external access

Time:11-11

Assuming that

The host IP: 192.168.1.100
IP: Docker container 172.10.0.5

What do the Docker containers IP via SSH can land directly, instead of using the hosting IP,,,

CodePudding user response:

Run container plus the -p parameter mapping ports such as docker run - itd - p 5000:5000

CodePudding user response:

This problem is a little let a person cannot find north, 172 at the beginning of the first segment is an Intranet section (which means you can only use on the host), if you host must be closed to access the network segment, you can go to the match the routing, the docker tube not, if you just want to log in directly by SSH container, then turn off the host the SSHD service first, then the docker plus in the run command - p and (if your mirror has a built-in SSHD service)

CodePudding user response:

Do port mapping, can refer to personal blog
https://blog.csdn.net/frdevolcqzyxynjds/article/details/107245548
Docker to create and run centos7 container
More wonderful, please pay attention to personal blog Linux column
https://blog.csdn.net/frdevolcqzyxynjds/category_9527729.html

CodePudding user response:

Docker run - d - p - 1122: name=SSH 22 alpine/sbin/init
Docker exec - ti # SSH into container
Apt add openssh # installation SSH service
Vi/etc/SSH/sshd_config # allows root login
Passwd # set the root password
SSH initialization - the keygen - A # keys
The/usr/sbin/SSHD # SSH service

Then you can pass the SSH root @ hostip -p 1122 into the container system
  • Related