Using docker-compose

   docker-compose --version

Create a docker-compose.yml File

  • Navigate to the root of your project where Dockerfile is also located, create a docker-compose.yml file. Below is a simple docker-compose.yml for a static site served by Nginx.
   version: '3.8'
   services:
   nginx:
      image: nginx:alpine
      ports:
         - "8089:80"
      volumes:
         - ./my-folder:/usr/share/nginx/html

Build and Run Containers

  • Run the command below in your terminal from the root of your project
   docker-compose up -d

  • The -d flag runs containers in the background.
  • Open a web browser and navigate to http://localhost:/ to verify that your service is running correctly.
  • Adjust based on your docker-compose.yml settings. In my example I use port 8089
  • Use docker-compose ps to check the status of running services.