ホストからdockerコンテナ内のnginxにcurl http://127.0.0.1:80/でアクセスして動いているかどうか確認したいです。docker psではコンテナ自体の起動されているのは確認済みです。また、healthcheckは設定しており、うまく接続できます。(docker-compose up -d でbuild&起動しています。)
http://127.0.0.1:80/
→ curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
http://127.0.0.1:80/healthcheck
→ curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
http://127.0.0.1:9080/
→ Internal Server Error
http://127.0.0.1:9080/healthcheck
→ 成功
上記の結果と下記のdockerの下記の状況をみるに、ポートフォワーディングできてはいるがアクセスがうまくいっていないようにみえます。どなたかご教示の方いましたら教えて頂けませんでしょうか?
bash-3.2$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 647906531af5 xxx_nginx "nginx -g 'daemon of…" 4 minutes ago Up 4 minutes 0.0.0.0:9080->80/tcp xxx_nginx_1 2b96b3070618 xxx_uwsgi "uwsgi --emperor /co…" 4 minutes ago Up 4 minutes 0.0.0.0:3031->3031/tcp, 8080/tcp xxx_uwsgi_1 0b6b815e327b mysql "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 33060/tcp, 0.0.0.0:13306->3306/tcp xxx_mysql_1
bash-3.2$ curl -v 127.0.0.1 * Rebuilt URL to: 127.0.0.1/ * Trying 127.0.0.1... * TCP_NODELAY set * Connection failed * connect to 127.0.0.1 port 80 failed: Connection refused * Failed to connect to 127.0.0.1 port 80: Connection refused * Closing connection 0 curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused bash-3.2$ cat /etc/hosts ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost dev-auth.xxx.jp dev-api.xxx.jp setting.hoge.xxx.jp 255.255.255.255 broadcasthost ::1 localhost #127.0.0.1 setting.hoge.xxx.jp
追記
docker-compose.yamlファイルは以下のようになっています。
ホスト側のOSは、macでdocker側のOSは、ubuntuになります。
version: "3" services: uwsgi: build: ./ volumes: - ~/local/xxx/work:/code/log/ ports: - "3031:3031" links: - mysql:mysql environment: TZ: "Asia/Tokyo" DATABASE_URL: "mysql+mysqldb://root:password@mysql/test_db?charset=utf8" DEBUG: 1 CONFIG: local nginx: build: ./nginx/local/ volumes: - ./nginx/local/nginx.conf:/etc/nginx/nginx.conf links: - uwsgi ports: - "9080:80" environment: TZ: "Asia/Tokyo" mysql: image: mysql volumes: - ~/local/xxx/work:/code/log/ ports: - "13306:3306" environment: MYSQL_ROOT_PASSWORD: password MYSQL_USER: test MYSQL_PASSWORD: test MYSQL_DATABASE: test_db

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/08 00:39
2018/11/08 02:25
2018/11/08 09:05
2018/11/08 10:08