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