我一直在尝试为在Vagrant中运行的Docker容器启用ssh访问。我快到了。但是,当我运行Vagrant时,我一直都会遇到错误。
这是我的Vagrant文件:
Vagrant.configure("2") do |config|
config.vm.define "app" do |app|
app.vm.provider "docker" do |d|
d.build_dir = "./Docker"
d.cmd = ["/sbin/init", "--enable-insecure-key"]
d.has_ssh = true
end
end
config.ssh.username = "root"
config.ssh.private_key_path = "./insecure_key"
end
这是我的Dockerfile:
# Unsecure key
FROM phusion/baseimage
RUN rm -f /etc/service/sshd/down
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
RUN /usr/sbin/enable_insecure_key
#ADD /home/renato/.ssh/id_rsa.pub /tmp/id_rsa.pub
#RUN cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys && rm -f /tmp/id_rsa.pub
# Ubuntu
FROM ubuntu:latest
MAINTAINER Tyler Cipriani, tyler@tylercipriani.com
# Download and install php, nginx, and supervisor, hey, just linux for a change!
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:nginx/stable
RUN apt-get update
RUN apt-get -y dist-upgrade
RUN apt-get install -y php5-fpm nginx supervisor
# Setup config files
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
ADD ./nginx/default /etc/nginx/sites-enabled/default
ADD ./supervisor/supervisord.conf /etc/supervisor/supervisord.conf
ADD ./php-fpm/php-fpm.conf /etc/php5/fpm/php-fpm.conf
# Shared volume
RUN mkdir -p /var/www
VOLUME ["/var/www"]
# Default command for container, start supervisor
CMD ["supervisord", "--nodaemon"]
USER root
# Expose port 80 of the container
EXPOSE 80
我从这里得到的ssh密钥。
https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key
任何帮助都会非常感激。
答案 0 :(得分:2)
由于Dockerfile中有两个FROM
指令,因此将构建两个不同的docker镜像。看起来流浪汉只能看到没有任何ssh服务的最后一个(FROM ubuntu:latest
)。
由于phusion/baseimage本身是由ubuntu:14.04
构建的,并且在这种情况下拥有2个不同的泊坞窗图像肯定不是您的目标,因此您不需要拥有第二个FROM
您的Dockerfile中的指令。只需删除它并尝试一下。