Iniciar un shell en el contenedor Docker Alpine


Para iniciar un shell interactivo para la imagen de Ubuntu podemos ejecutar:

ole@T:~$ docker run -it --rm ubuntu
root@1a6721e1fb64:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

Pero cuando esto se ejecuta para la imagen Alpine Docker , los siguientes resultados:

ole@T:~$ docker run -it --rm alpine
Error response from daemon: No command specified

¿Cuál es el comando para iniciar un shell interactivo en un contenedor base Alpine?

Author: Peter Mortensen, 2016-02-29

2 answers

ole@T:~$ docker run -it --rm alpine /bin/ash
(inside container) / # 

Opciones utilizadas anteriormente:

  • /bin/ash es Ceniza (Almquist Shell ) proporcionada por BusyBox
  • --rm Retire automáticamente el contenedor cuando salga (docker run --help)
  • -i Modo interactivo (Mantenga la STDIN abierta incluso si no está adjunta)
  • -t Asignar un pseudo-TTY
 138
Author: Ole,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-02 22:50:41

Por lo general, una imagen de Alpine Linux no contiene bash, en su lugar puede utilizar /bin/ash, /bin/sh, ash o solo sh.

/ bin / ash

docker run -it --rm alpine /bin/ash

/bin / sh

docker run -it --rm alpine /bin/sh

Ash

docker run -it --rm alpine ash

Sh

docker run -it --rm alpine sh

Espero que esta información le ayude.

 36
Author: jansanchez,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-22 20:22:31