3

我目前正在使用来自 DockerHub ( https://hub.docker.com/r/microsoft/azure-storage-emulator/ ) 的 microsoft/azure-storage-emulator 映像在 Docker 容器中运行 Azure Storage Emulator。

但是,我想做的是从一个单独的 Docker 容器连接到模拟器。

看起来图像使用 nginx 反向代理(我不知道微软为什么这样做)将请求转发到模拟器。

将模拟器配置文件更新为正在运行的容器的 IP 地址是相当直接的:

<StorageEmulatorConfig>
    <services>
        <service name="Blob" url="http://172.20.0.220:20000/"/>
        <service name="Queue" url="http://172.20.0.220:20001/"/>
        <service name="Table" url="http://172.20.0.220:20002/"/>
    </services>

...

但是,我想弄清楚我需要为 nginx 配置文件更改什么才能访问容器中的模拟器。

我认为server_name需要更新为正在运行的容器的名称,proxy_pass需要更新容器的IP?

http {
proxy_http_version 1.1;
access_log off; # find way to redirect log to stdout on winodws

server {
    listen       10000;
    server_name  storage;

    location / {
        proxy_pass http://172.20.0.220:20000;
    }
}

server {
    listen       10001;
    server_name  storage;

    location / {
        proxy_pass http://172.20.0.220:20001;
    }
}

server {
    listen       10002;
    server_name  storage;

    location / {
        proxy_pass http://172.20.0.220:20002;
    }
}

当我从 Microsoft 基础映像构建自己的映像时,我通过我的 Dockerfile 公开端口 10000、10001 和 10002,以便容器可以在这些端口上接收请求:

FROM microsoft/azure-storage-emulator
EXPOSE 10000 10001 10002

我正在使用 DockerHub 的图像页面上推荐的连接字符串:

DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://{ip}:{blobport}/devstoreaccount1;TableEndpoint=http://;{ip}:{ QueueEndpoint=http://{ip}:{queueport}/devstoreaccount1;

但是在尝试从另一个容器连接到模拟器容器时,我不断收到此错误消息:

Failed to execute installers: Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (504) Gateway Timeout. ---> System.Net.WebException: The remote server returned an error: (504) Gateway Timeout. at System.Net.HttpWebRequest.GetResponse() at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) --- End of inner exception stack trace --- at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.CloudTable.Create(TableRequestOptions requestOptions, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExists(TableRequestOptions requestOptions, OperationContext operationContext) at NServiceBus.AzureStorageQueues.AzureStorageQueueInfrastructure..ctor(SettingsHolder settings, String connectionString) at NServiceBus.AzureStorageQueueTransport.Initialize(SettingsHolder settings, String connectionString) at NServiceBus.InitializableEndpoint.<Initialize>d__1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NServiceBus.Hosting.Windows.InstallWindowsHost.Install(String username) at NServiceBus.Hosting.Windows.Installers.WindowsInstaller.RunInstall() Request Information RequestID: RequestDate:Wed, 14 Mar 2018 02:19:41 GMT StatusMessage:Gateway Time-out

所以,我不太确定我需要对 nginx 配置文件进行哪些更改才能让一个容器访问另一个容器中的模拟器,或者我想要做的事情是否可行。

谢谢,米克

4

0 回答 0