Dockerコンテナ内のWCFサービスを公開するアプリケーションを実行しようとしています。DockerコンテナでホストされているWCFサービスに接続できません。
アプリケーションはTopShelfを使用して構築されているため、Windowsサービスとして、または(開発中)スタンドアロンのコンソールプログラムとして実行できます。
私が経験している問題は、WCFテストクライアントがメタデータを取得できないことです。アプリケーションがローカルで実行されたときに正しく動作することは重要です。ここで
は、アプリケーションがこれは私が構築した後、ビルドにコンテナ
FROM microsoft/dotnet-framework:4.6.2
RUN powershell -Command Add-WindowsFeature NET-WCF-HTTP-Activation45
WORKDIR app
COPY bin/Release/net461 .
EXPOSE 9998 9999
ENTRYPOINT ["EMG.Service.TestWcfDocker.exe"]
を使用していDockerfileあるローカル
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ITestWcfDocker" sendTimeout="00:05:00">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:9998/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_ITestWcfDocker" contract="ITestWcfDocker"
name="NetTcpBinding_ITestWcfDocker" />
</client>
</system.serviceModel>
</configuration>
を実行しているとき、WCFテストクライアントによって生成されたメタデータファイルでありますプロジェクト、私はこのコマンドでコンテナを構築する
docker build -t emg/test-wcf:latest .
その後私はこのコマンドを使用してコンテナを起動
docker run -p 9998:9998 -p 9999:9999 -t emg/test-wcf
これは私がコンソールログに取得する出力
Configuration Result:
[Success] Name EMG.TestWcfDocker, [Success] DisplayName EMG TestWcfDocker, [Success] Description EMG TestWcfDocker, [Success] ServiceName EMG.TestWcfDocker
Topshelf v4.0.0.0, .NET Framework v4.0.30319.42000
2017-05-15 15:46:48.0700|DEBUG|WcfServiceHost|Adding NetTcpBinding endpoint for ITestWcfDocker at net.tcp://localhost:9998/
2017-05-15 15:46:48.1012|DEBUG|WcfServiceHost|Adding Metadata endpoint at http://localhost:9999/
2017-05-15 15:46:49.2207|INFO|EMG.TestWcfDocker.Program|Starting EMG.TestWcfDocker
The EMG.TestWcfDocker service is now running, press Control+C to exit.
2017-05-15 15:46:50.2675|INFO|EMG.TestWcfDocker.Program|EMG.TestWcfDocker started
コンテナが開始されると、私はコンテナ
docker inspect -f="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" container-name
のIPを取得するには、これを使用しています
返されたIPを使用して、WCFテストクライアント経由でサービスに接続しましたが、このエラーメッセージが表示されます。
Error: Cannot obtain Metadata from http://172.19.111.72:9999/ If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://172.19.111.72:9999/ Metadata contains a reference that cannot be resolved: 'http://172.19.111.72:9999/'. There was no endpoint listening at http://172.19.111.72:9999/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. Unable to connect to the remote server A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.19.111.72:9999HTTP GET Error URI: http://172.19.111.72:9999/ There was an error downloading 'http://172.19.111.72:9999/'. Unable to connect to the remote server A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.19.111.72:9999
localhostを使用すると、同様のエラーが発生します。
TL; DR:
私はドッカーコンテナ内のWCFサービスを持って、私は、ホストマシンから接続することはできません。
サービスのweb.configにメタデータを公開していますか? a? <バインド名> "バインディング名" "名前="メキシコ "契約=" IMetadataExchange ">'またはあなたはサービスバーチャリゼーションのメタデータを取得できますか? ? ' ' –
Popo
@Popo設定ファイルはありません.WCF設定全体はコードで行われます。とにかく、あなたの質問に答えるために、ServiceMetadataBehaviorをサービスホストに追加しました。これは、アプリケーションをローカルで実行するときに正しく動作する理由です。 – Kralizek
コンテナに直接接続することはお勧めしません。代わりに、ドッカーポート公開システムを使用する必要があります。 – programmerq