前提・実現したいこと
自作したWebアプリケーションをDockerコンテナで起動し外部から接続したいです.
KotlinのKtorを使用しました.
jarを作成してDockerコンテナ内で起動させました.
発生している問題・エラーメッセージ
localの8000番をコンテナの8000番に接続しています.
Docker内で起動はしているのですが,ポートフォワードがうまくいきません.
32103b2b3eca log-api "java -jar log-api-1…" 16 minutes ago Up 16 minutes 0.0.0.0:8000->8000/tcp log-api
curlコマンドの実行
username$ curl localhost:8000/ curl: (52) Empty reply from server
該当のソースコード
FROM openjdk:12-jdk-oracle Expose 8000 RUN mkdir ./work COPY . /work WORKDIR /work ENTRYPOINT ["java","-jar","log-api-1.0-SNAPSHOT.jar"]
試したこと
dockerコンテナ内での実行はうまく行きます.
$ docker exec -it 32103b2b3eca /bin/bash bash-4.2# curl localhost:8000/ hello
nginxはうまく行きました
$ docker run --name example -d -p 8080:80 nginx 744d52dee78d35900237433b760ed7c8d56e32e4eb9f6063c406884a3f7c83cb $ curl localhost:8080 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
補足情報(FW/ツールのバージョンなど)
docker-for-macを使用しています
Docker version 18.09.2, build 6247962
Ktorのapplicaton.cong
ktor { deployment { host = "127.0.0.1" port = 9000 port = ${?PORT} } application { modules = [ rest.CalendarAppKt.module ] } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/26 08:06