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 get true or false as a response from docker if the service is running or not
  • npm install errors out saying ' Error: getaddrinfo ENOTFOUND npm.lab.myorg.com'
  • Why is my docker node container exiting
  • sharing docker.sock or docker in docker (dind)
  • Running .Net Core in Docker in Windows Subsystem for Linux
  • Docker on RHEL 7 in AWS can’t pull images
  • 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, 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
    

    The ssh key I got from here.

    https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key

    Error in my screen:
    enter image description here

    Any help would be really appreciated.

  • Updating docker registry in ubuntu 14.0
  • How to forward an additional port to docker container created by mupx?
  • Elastic Beanstalk environment variables for Docker host
  • Schema Registry container: Server died unexpectedly when launching using docker-compose
  • Docker container communicating with external database
  • seeding mysql data in a docker build
  • 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.