Access docker without SSH

Source: Internet
Author: User

From: http://www.sebastien-han.fr/blog/2014/01/27/access-a-container-without-ssh/

Run a simple memcache container first:

$ Sudo docker run-D-P 11211 bacongobbler/memcached/usr/bin/memcached-M 64-P 11211-u memcache-l 0.0.0.0 $ sudo docker pscontainer ID image Command created status ports names0a9856723f90 192.168.0.127: 5042/memcached: Latest memcached/usr/bin/m 2 seconds ago up 2 seconds 0.0.0.0: 49153-& gt; 11211/tcp pensive_pasteur
123456 $ Sudo docker run-d-p11211 bacongobbler/memcachedmemcached/usr/bin/memcached-m64-p11211-umemcache-l0.0.0.0 $ sudo docker pscontainer ID image Command created status ports hosts 192.168.0.127: 5042/memcached: latest memcached/usr/bin/m 2 secondsago up2 seconds 0.0.0.0: 49153-& gt; 11211/tcp pensive_pasteur

Obtain the PID of the process running in docker:

Root @ docker :~ # Ps faux | grep memcachedsyslog 29123 0.0 0.0 323216 1184? Sl \ _ memcached/usr/bin/memcached-M 64-P 11211-u memcache-l 0.0.0.0
123 Root @ docker :~ # Ps faux | grep memcachedsyslog 29123 0.0 0.0323216 1184? Sl \ _ memcached/usr/bin/memcached-m64-p000011-umemcache-l0.0.0.0

Install the nsenter command (in the util-linux package), which requires Linux 2.23release.

$ Wget unzip Bzip2-D-C util-linux-2.24.tar.bz2 | tar xvf-$ CD util-linux-2.24/$ sudo./configure -- without-ncurses $ make nsenter $ CP nsenter/usr/local/bin
1234567 $ Wget alert bzip2-d-cutil-linux-2.24.tar.bz2 | tarxvf-$ CD util-linux-2.24/$ sudo./configure -- without-ncurses $ make nsenter $ cpnsenter/usr/local/bin

Then, we connect to the docker container.

$ Sudo nsenter-m-u-I-n-p-t 29123/bin/sh # ps fauxuser PID % CPU % mem vsz RSS tty stat start time commandroot 11 0.0 0.0 4396 608? S/bin/shroot 12 0.0 0.0 15272 1100? R + \ _ PS fauxmemcache 1 0.0 0.0 323216 1184? SL memcached/usr/bin/memcached-M 64-P 11211-u memcache-l 0.0.0.0
1234567 $ Sudo nsenter-m-u-i-n-p-t29123/bin/sh # ps fauxuser PID % CPU % mem vsz RSS tty statstart time commandroot 11 0.0 0.0 4396 608? S/bin/shroot 12 0.0 0.0 15272 1100? R + \ _ PS fauxmemcache 1 0.0 0.0323216 1184? SL 0: 00 memcached/usr/bin/memcached-m64-p000011-umemcache-l0.0.0.0

Access docker without SSH

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.