How to install OpenSSH on Alpine?

When running an alpine docker container for the first time and attempting to install openssh, I get the following error:

ole@T:~$ docker run -it --rm alpine /bin/ash
/ # apk add openssh
WARNING: Ignoring APKINDEX.d3812b7e.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.bb2c5760.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  openssh (missing):
    required by: world[openssh]

How can I install openssh?


  • Run apk update first.

    A complete example:

        ole@T:~$ docker run -it --rm alpine /bin/ash
        / # apk update
        v3.3.1-97-g109077d []
        v3.3.1-59-g48b0368 []
        OK: 5853 distinct packages available
        / # apk add openssh
        (1/3) Installing openssh-client (7.1_p2-r0)
        (2/3) Installing openssh-sftp-server (7.1_p2-r0)
        (3/3) Installing openssh (7.1_p2-r0)
        Executing busybox-1.24.1-r7.trigger
        OK: 8 MiB in 14 packages