Docker in Vagrant issuing : Warning: Connection refused. Retrying
I’ve been try to enable ssh access for Docker’s containers running in Vagrant. I’m almost there. However, I keep getting errors when I run Vagrant up.
Here is my Vagrant file:
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
Here is my 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, firstname.lastname@example.org # 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
The ssh key I got from here.
Error in my screen:
Any help would be really appreciated.
One Solution collect form web for “Docker in Vagrant issuing : Warning: Connection refused. Retrying”
Since you have two
FROM directives in your Dockerfile, two different docker images will be built. It seems vagrant sees only the last one (
FROM ubuntu:latest) which does not have any ssh service.
As the phusion/baseimage is itself built from
ubuntu:14.04 and as having 2 different docker images is certainly not your goal in this case, you don’t need to have that second
FROM instruction in your Dockerfile. Just remove it and give it a try.