ksaitoの日記

日々試したことの覚え書き

dockerでgnu screenを使う

移転しました。

自動的にリダイレクトします。

dockerコンテナでGNU screenを使えるようにしてみました。

環境

試した環境は、以下の通りです。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:    16.04
Codename:   denial
$ docker --version
Docker version 1.12.2, build bb80604
$ sudo docker run -it -d ubuntu:16.04 bash
$

screenのインストールと起動

コンテナに接続してscreenを起動するとttyがないので起動できません。

$ sudo docker exec -it ecstatic_williams bash
root@d82a18f67359:/# apt update && apt install -y screen
root@d82a18f67359:/# screen
Must be connected to a terminal.
root@d82a18f67359:/# tty
not a tty
root@d82a18f67359:/# 

ttyを設定

ngettyパッケージでgettyttyを設定します。

root@d82a18f67359:/# apt install -y ngetty
root@d82a18f67359:/# useradd -m test
root@d82a18f67359:/# passwd test
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@d82a18f67359:/# getty tty 

Ubuntu 16.04.1 LTS d82a18f67359 tty

d82a18f67359 login: test
Password: 
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-45-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

test@d82a18f67359:~$ tty
/dev/tty
test@d82a18f67359:~$ 

ttyが設定されたのでscreenも無事起動しました。

test@d82a18f67359:~$ screen
Screen version 4.03.01 (GNU) 28-Jun-15

Copyright (c) 2010 Juergen Weigert, Sadrul Habib Chowdhury
Copyright (c) 2008, 2009 Juergen Weigert, Michael Schroeder, Micah Cowan, Sadrul Habib Chowdhury
Copyright (c) 1993-2002, 2003, 2005, 2006, 2007 Juergen Weigert, Michael Schroeder
Copyright (c) 1987 Oliver Laumann

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either
version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program (see the file COPYING); if not, see http://www.gnu.org/licenses/, or contact Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA.

Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza to screen-devel@gnu.org


Capabilities:
+copy +remote-detach +power-detach +multi-attach +multi-user +font +color-256 +utf8 +rxvt +builtin-telnet