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:

  • How to copy a specific docker image layer from one host to another?
  • Assign port to container
  • Running bazel with sandboxing in a Docker container
  • How to launch AVD while keep running docker
  • access docker VM in private network (docker-machine)
  • Chrome browser keeps crashing when running on android emulator in docker container
  • 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
      config.ssh.username = "root"
      config.ssh.private_key_path = "./insecure_key"

    Here is my Dockerfile:

    # Unsecure key
    FROM phusion/baseimage
    RUN rm -f /etc/service/sshd/down
    RUN /etc/my_init.d/
    RUN /usr/sbin/enable_insecure_key
    #ADD /home/renato/.ssh/ /tmp/
    #RUN cat /tmp/ >> /root/.ssh/authorized_keys && rm -f /tmp/
    # Ubuntu
    FROM ubuntu:latest
    MAINTAINER Tyler Cipriani,
    # 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:
    enter image description here

    Any help would be really appreciated.

  • running docker remotely on openvz
  • Using Docker in local development [closed]
  • Tomcat freezes in Docker container when starting
  • Dockerfile COPY {source-…}
  • Version error when installing docker toolbox on OSX
  • How can I get a Docker image's label if the label name has a “.” in it?
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.