Set up an SSH tunnel into the container, using the host as a gateway host.

    Args:
        * container: Container name or ID
        * local_port: Local port
        * remote_port=None: Port on the Docker container (defaults to local_port)
        * gateway_port=None: Port on the gateway host (defaults to remote_port)

def tunnel(container, local_port, remote_port=None, gateway_port=None):
    '''
    Set up an SSH tunnel into the container, using the host as a gateway host.

    Args:
        * container: Container name or ID
        * local_port: Local port
        * remote_port=None: Port on the Docker container (defaults to local_port)
        * gateway_port=None: Port on the gateway host (defaults to remote_port)
    '''
    if remote_port is None:
        remote_port = local_port
    if gateway_port is None:
        gateway_port = remote_port

    remote_host = get_ip(container)

    command = '''
        ssh -v
            -o StrictHostKeyChecking=no
            -i "%(key_filename)s"
            -L %(local_port)s:localhost:%(gateway_port)s
            %(gateway_user)s@%(gateway_host)s
                sshpass -p root
                    ssh -o StrictHostKeyChecking=no
                        -L %(gateway_port)s:localhost:%(remote_port)s
                            root@%(remote_host)s
    ''' % {
        'key_filename': env.key_filename,
        'local_port': local_port,
        'gateway_port': gateway_port,
        'gateway_user': env.user,
        'gateway_host': env.host,
        'remote_port': remote_port,
        'remote_host': remote_host,
    }

    command = command.replace('\n', '')

    local(command)