Docker-Compose,如何创建一个包括后端应用程序+数据库/

发布于 2025-01-29 21:58:13 字数 1108 浏览 1 评论 0原文

我是Docker-Compose的新手,我想创建我最近构建的应用程序的图像。

我唯一的问题是,当我运行docker-compose在本地起作用时(即Docker从Docker Hub中摘下Mariadb图像并相应地构建我的后端),我可以通过我的后端访问它浏览器和bla bla。

现在是时候在Azure上部署该应用程序了,我注意到它没有构建预构建的Mariadb图像。它仅构建后端应用程序,导致部署故障。

docker-compose.yml

    version: '3.2'
services:

  db:
    container_name: test-db
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: saicom
    ports:
      - 3306:3306
    networks:
      - app-network  

  be:
    container_name: test-be
    build:
      context: .
      dockerfile: 'Dockerfile'
    ports:
      - '8080:4200'
    depends_on:
      - "db"
    networks:
      - app-network
     

networks:
  app-network:
    driver: bridge

我试图评论docker-compose.yml文件中的服务 它给了这个

我不确定为什么Docker-Compose会跳过Mariadb图像而不将其包含在我的应用中。

我需要一个好的撒玛利亚人来向我解释我的构建有什么问题。

提前致谢

I'm fairly new to docker-compose and I wanted to create an image of an application that I've built recently.

The only issue that I'm having is that when I run docker-compose up locally it works (i.e docker pulled both the MariaDB image from docker hub and built my backend accordingly) I can access it via my browser and bla bla.

Now comes the time to deploy the app on azure and I noticed that it's not building the prebuilt MariaDB image. It is only building the backend app causing deployment failure.

docker-compose.yml

    version: '3.2'
services:

  db:
    container_name: test-db
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: saicom
    ports:
      - 3306:3306
    networks:
      - app-network  

  be:
    container_name: test-be
    build:
      context: .
      dockerfile: 'Dockerfile'
    ports:
      - '8080:4200'
    depends_on:
      - "db"
    networks:
      - app-network
     

networks:
  app-network:
    driver: bridge

I tried to comment the be service in the docker-compose.yml file
and it is giving this
enter image description here

I'm not sure why docker-compose is skipping the MariaDB image and not including it in my app.

I need a good samaritan to explain me what's wrong with my build.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文