【发布时间】:2021-07-01 20:52:36
【问题描述】:
我正在尝试学习 docker,我在 education.io 上找到了这门课程。
为什么我在 /Docker 目录中使用 docker compose up,一切正常,但是当我尝试在浏览器中导航到“127.0.0.1:5000”时,我收到了该错误。
我有以下 docker-compose 文件:
version: '3'
services:
web:
# Path to dockerfile.
# '.' represents the current directory in which
# docker-compose.yml is present.
build: .
# Mapping of container port to host
ports:
- "5000:5000"
# Mount volume
volumes:
- "C:/Users/Docker/:/code"
# Link database container to app container
# for rechability.
links:
- "database:backenddb"
database:
# image to fetch from docker hub
image: mysql/mysql-server:5.7
# Environment variables for startup script
# container will use these variables
# to start the container with these define variables.
environment:
- "MYSQL_ROOT_PASSWORD=root"
- "MYSQL_USER=testuser"
- "MYSQL_PASSWORD=admin123"
- "MYSQL_DATABASE=backend"
# Mount init.sql file to automatically run
# and create tables for us.
# everything in docker-entrypoint-initdb.d folder
# is executed as soon as container is up nd running.
volumes:
- "C:/Users/Docker/db/init.sql:/docker-entrypoint-initdb.d/init.sql"
包含flask env和所有需求的代码可以在这个repo中找到:
https://github.com/venky8283/Docker
你只需要结帐提交:4de325cf1da2428e757be4f2bcc53f35c384c598
【问题讨论】:
标签: python-3.x docker flask docker-compose