Based on a YAML file (that works as a manifet file), the Docker Compose tool manages Docker containers.

⚙️ Setup

Initializing a docker compose environment

First of all, we have to create a docker-compose.yaml file. This file is going to specify which services we want to run through Docker. It'll work as our manifesto.

version: {docker-compose-version}

services: 

  {service-name}: 
    image: {docker-image}
    container_name: {container-name}
    networks:
      - {network-name} 
    ports:
			- "{host-port}:{container-port}"			

  {service-name}: 
    image: {custom-image-name}
		build:
			context: ./myimage
			dockerfile: Dockerfile
    container_name: {container-name}
    networks:
      - {network-name}
		ports:
			- "{host-port}:{container-port}"

	{service-name}: 
    image: {custom-image-name}
		command: {custom-command}
    container_name: {container-name}
		restart: {restart-value}
    tty: {true | false}
    volumes:
			- {host-directory}:{container-directory}
		environment:
			- {var_name}={var_value}
    networks:
      - {network-name}
		ports:
			- "{host-port}:{container-port}"

networks:
	{network-name}:
		driver: {network-type}

Properties:

After preparing our Docker Compose file, we can run everything through the command: docker-compose up


💻 Commands

docker-compose up : Runs all services/containers

<aside> 💡 Example: docker-compose up {commands}

</aside>

docker-compose down: Closes all services/containers

docker-compose ps: Lists all services/containers of our Docker Compose environment