In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how the Linux host uses ssh to log in to the docker container". In the daily operation, I believe that many people have doubts about how the Linux host uses ssh to log in to the docker container. The editor has consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the question of "how to log in to the docker container with ssh in the Linux host". Next, please follow the editor to study!
Host: XUbuntu 15.04 + docker
Enter the terminal, sudo-I, switch root, and enter docker-d
Open another terminal, switch root, and type docker search ubuntu. The result is as follows:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
Ubuntu Ubuntu is a Debian-based Linux operating s... 2306 [OK]
Ubuntu-upstart Upstart is an event-based replacement for... 33 [OK]
Torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 25 [OK]
Tleyden5iwx/ubuntu-cuda Ubuntu 14.04 with CUDA drivers pre-installed 18 [OK]
Ubuntu-debootstrap debootstrap-variant=minbase-components... 14 [OK]
Guilhem/vagrant-ubuntu 11 [OK]
Enter docker pull ubuntu and the system will download the image from the first one.
After the download is complete, you can enter docker images to check whether the image has been downloaded to the local image.
Start a ubuntu container and enter bash,docker run-it ubuntu / bin/bash
At this point, you should see root@bc6a0a7912b1:/#, which proves that the container has been started successfully and entered the bash of the container.
Change the root password of the container: passwd until you enter a new password, for example: 123456
Install vim,apt-get install vim-y
To install the openssh-server of the container, type apt-get install openssh-server-y
After successful installation, vim / etc/ssh/sshd_config, modify the following two configurations
PermitRootLogin yes
UsePAM no
Start the ssh service, service ssh start
Exit the container, type exit, and then type docker ps-a to view the ID of the container
Submit the container to a new image, such as ubuntu-ssh, enter the docker commit container ID ubuntu-ssh
Start the mirrored container and map an idle local port (for example, 10000) to port 22 of the container, and start the container's sshd docker run-d-p 10000 usr/sbin/sshd 22 ubuntu-ssh / usr/sbin/sshd-D.
Now open a new terminal and enter ssh root@127.0.0.1-p 10000. If the link is successful, you will be asked to enter the password. Enter the 123456 just now to enter the terminal of the container.
At this point, the study on "how the Linux host uses ssh to log in to the docker container" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.