Docker Ubuntu 18.04 SSH密钥扫描

时间:2019-03-12 15:15:43

标签: docker dockerfile ubuntu-18.04

希望有人已经解决了这个问题。

我想将docker镜像从Ubuntu 16.04升级到Ubuntu 18.04。 除了以下内容,一切似乎都很好:

RUN apt-get install -y ssh
RUN mkdir -p /home/sshkeys
RUN ssh-keygen -q -t rsa -N '' -f /home/sshkeys/id_rsa 
RUN touch /home/sshkeys/authorized_keys
RUN cat /home/sshkeys/id_rsa.pub >> /home/sshkeys/authorized_keys
RUN ./etc/init.d/ssh start
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config     
**RUN ssh-keyscan localhost >> /home/postgres/.ssh/known_hosts**

使用Ubuntu 16.04可以正常工作,但是在Ubuntu 18.04中,从Dockerfile构建图像时出现以下错误:

Step 36/71 : RUN ssh-keyscan localhost >> /home/postgres/.ssh/known_hosts
 ---> Running in 0f34b430fc2f
write (localhost): Connection refused
write (localhost): Connection refused
write (localhost): Connection refused
Removing intermediate container 0f34b430fc2f

1 个答案:

答案 0 :(得分:0)

您应在与{ "Start": "2019-06-10T13:30:15.2105502Z", "End": "2019-06-10T13:30:15.3055115Z", "ExitCode": -1, "Output": "OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused \"exec: \\\"curl\\\": executable file not found in $PATH\": unknown" } 相同的层中启动mydocker: image: mydocker container_name: mydockername hostname: mydockerhostname healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 1m30s timeout: 10s retries: 3 networks: - confluent ports: - "8080-8090:8080" volumes: - myvolume:/pathname command: - start - --insecure ,默认情况下,它不在新层中启动,因此只需在同一sshd中耦合命令即可:

ssh-keyscan