steam吧 关注:4,541,817贴子:70,730,464
  • 3回复贴,共1

【docker技术求助】创建容器怎么指定网络?默认是bridge模式。

只看楼主收藏回复

服务器官方创建容器命令是: cd obico-server; docker compose up -d 默认是bridge模式
创建完无法访问容器内的网页。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: '${EMAI
L_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-12 15:08回复
    没细看。你直接指定一个network参数不行吗


    IP属地:江苏来自Android客户端2楼2023-10-12 17:35
    收起回复