Ask Your Question
2

How can MongoDB be used in Azure App Service through Docker-Compose?

asked 2023-05-06 09:08:46 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-06 09:30:01 +0000

david gravatar image

To use MongoDB in Azure App Service through Docker-Compose, follow these steps:

  1. Create a new Docker-Compose file in your project directory and add the following code:
version: "3.8"
services:
  app:
    build: .
    ports:
      - "3000:3000"
    depends_on:
      - db
    environment:
      - MONGODB_URI=mongodb://db:27017/mydatabase
  db:
    image: mongo:latest
    restart: always
    volumes:
      - db_data:/data/db
volumes:
  db_data:
  1. Replace the "mydatabase" with the name of your database that you want to connect to.

  2. Create a new Azure App Service instance and configure it to use Docker-Compose for deployment.

  3. Deploy your application to Azure App Service by uploading your Docker-Compose file.

  4. Verify that your application is running by checking the logs of your Azure App Service instance.

  5. Connect to MongoDB by using the MONGODB_URI environment variable that you defined in your Docker-Compose file.

Now you can use MongoDB in Azure App Service through Docker-Compose.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-06 09:08:46 +0000

Seen: 14 times

Last updated: May 06 '23