Starting a shell in the Docker Alpine container

Ole picture Ole · Feb 29, 2016 · Viewed 163.9k times · Source

To start an interactive shell for the Ubuntu image we can run:

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

But when this is run for the Alpine Docker image, the following results:

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

What is the command for starting an interactive shell in an Alpine base container?

Answer

Ole picture Ole · Feb 29, 2016
ole@T:~$ docker run -it --rm alpine /bin/ash
(inside container) / # 

Options used above:

  • /bin/ash is Ash (Almquist Shell) provided by BusyBox
  • --rm Automatically remove the container when it exits (docker run --help)
  • -i Interactive mode (Keep STDIN open even if not attached)
  • -t Allocate a pseudo-TTY