docker吧 关注:6,043贴子:6,444
  • 2回复贴,共1

求助!创建容器怎么指定网络?默认是bridge模式。无法外网访问

只看楼主收藏回复

原本要创建的容器命令是: cd obico-server; docker compose up -d
创建完无法访问容器内的网页。127.0.0.1+端口不行。但是容器给的loc那个地址可以。
查了很多教程后说是要改docker-compose配置文件。但是我看了很多模板也测试了很多次都不行。
所以求助下贴吧老哥能不能帮忙看下
docker-compose配置内容如下:
version: '2.4'
x-web-defaults: &web-defaults restart: unless-stopped build: context: backend dockerfile: 'Dockerfile' volumes: - ./backend:/app - ./frontend:/frontend depends_on: - redis environment: OCTOPRINT_TUNNEL_PORT_RANGE: '0-0' EMAIL_HOST: '${EMAIL_HOST-}' EMAIL_HOST_USER: '${EMAIL_HOST_USER-}' EMAIL_HOST_PASSWORD: '${EMAIL_HOST_PASSWORD-}' EMAIL_PORT: '${EMAIL_PORT-587}' EMAIL_USE_TLS: '${EMAIL_USE_TLS-True}' DEFAULT_FROM_EMAIL: '${DEFAULT_FROM_EMAIL-changeme@example.com}' DEBUG: '${DEBUG-False}' # Don't set DEBUG to True unless you know what you are doing. Otherwise the static files will be cached in browser until hard-refresh ADMIN_IP_WHITELIST: '${ADMIN_IP_WHITELIST-}' SITE_USES_HTTPS: '${SITE_USES_HTTPS-False}' SITE_IS_PUBLIC: '${SITE_IS_PUBLIC-False}' SOCIAL_LOGIN: '${SOCIAL_LOGIN-False}' REDIS_URL: '${REDIS_URL-redis://redis:6379}' DATABASE_URL: '${DATABASE_URL-sqlite:////app/db.sqlite3}' INTERNAL_MEDIA_HOST: '${INTERNAL_MEDIA_HOST-http://web:3334}' ML_API_HOST: '${ML_API_HOST-http://ml_api:3333}' ACCOUNT_ALLOW_SIGN_UP: '${ACCOUNT_ALLOW_SIGN_UP-False}' WEBPACK_LOADER_ENABLED: '${WEBPACK_LOADER_ENABLED-False}' TELEGRAM_BOT_TOKEN: '${TELEGRAM_BOT_TOKEN-}' TWILIO_ACCOUNT_SID: '${TWILIO_ACCOUNT_SID-}' TWILIO_AUTH_TOKEN: '${TWILIO_AUTH_TOKEN-}' TWILIO_FROM_NUMBER: '${TWILIO_FROM_NUMBER-}' SENTRY_DSN: '${SENTRY_DSN-}' PUSHOVER_APP_TOKEN: '${PUSHOVER_APP_TOKEN-}' SLACK_CLIENT_ID: '${SLACK_CLIENT_ID-}' SLACK_CLIENT_SECRET: '${SLACK_CLIENT_SECRET-}' VERSION:
services: ml_api: hostname: ml_api restart: unless-stopped build: context: ml_api environment: DEBUG: 'True' FLASK_APP: 'server.py' # ML_API_TOKEN: tty: true command: bash -c "gunicorn --bind 0.0.0.0:3334 --workers 1 wsgi"
web: <<: *web-defaults hostname: web ports: - "3334:3334" depends_on: - ml_api command: sh -c 'python manage.py migrate && python manage.py collectstatic -v 2 --noinput && python manage.py runserver --nostatic --noreload 0.0.0.0:3334'
tasks: <<: *web-defaults hostname: tasks command: sh -c "celery -A config worker --beat -l info -c 2 -Q realtime,celery"
redis: restart: unless-stopped image: redis:5.0-alpine


IP属地:天津1楼2023-10-09 14:10回复


    IP属地:天津2楼2023-10-09 14:15
    回复
      能外网访问就可以。求个大哥帮忙看看怎么改


      IP属地:天津3楼2023-10-09 14:15
      回复