2016-02-29 55 views
20

安裝OpenSSH當運行高山搬運工容器中的第一次和嘗試OpenSSH的安裝,會發生以下情況:了阿爾卑斯山泊塢集裝箱

[email protected]:~$ 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] 

應該如何OpenSSH的安裝?

+2

不回答,只是分享:如果您在Docker容器運行SSHD,你就錯了!(https://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil /)[jpetazzo](https://github.com/jpetazzo/) - docker dev。 – Auzias

+0

你好@Auzias - 優秀的文章 - 謝謝。我正在安裝SSH服務器,以便能夠同時瞭解有關SSH和Alpine的更多信息。基本上是一個玩具實驗。 – Ole

+0

@Auzias,ssh'ing容器對遠程調試python應用程序很有用。 – Pitt

回答

37

首先運行apk update。下面膏含有完整的例子:

[email protected]:~$ docker run -it --rm alpine /bin/ash 
    /# apk update 
    fetch http://dl-4.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz 
    fetch http://dl-4.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz 
    v3.3.1-97-g109077d [http://dl-4.alpinelinux.org/alpine/v3.3/main] 
    v3.3.1-59-g48b0368 [http://dl-4.alpinelinux.org/alpine/v3.3/community] 
    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 
+7

或者,執行並更新並添加一擊:'運行apk添加 - 更新openssh' –