How to Install docker-compose and Run containers in Nodegrid

How to Install docker-compose and Run containers in Nodegrid

Docker-Compose

Follow these steps to install docker-compose in Nodegrid.

Prerequisite:
- Docker license must be installed
- Docker must be enabled and running

1. Login as admin in CLI and type shell sudo su - to go to shell
2. Type these commands,

mount -o remount, rw /
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
mount -o remount, ro /

This will install docker-compose and you can check via typing docker-compose and enter. This will show the commands.


 Optional: Example to run multiple application containers with docker-compose

vim docker-compose.yml

Enter these data and save the file.


  1. services:
       db:
         image: mysql:5.7
         volumes:
           - db_data:/var/lib/mysql
         restart: always
         environment:
           MYSQL_ROOT_PASSWORD: 12345678
           MYSQL_DATABASE: wordpress
           MYSQL_USER: wordpress
           MYSQL_PASSWORD: wordpress

       wordpress:
         depends_on:
           - db
         image: wordpress:latest
         ports:
           - "8000:80"
         restart: always
         environment:
           WORDPRESS_DB_HOST: db:3306
           WORDPRESS_DB_USER: wordpress
           WORDPRESS_DB_PASSWORD: wordpress
           WORDPRESS_DB_NAME: wordpress
    volumes:
        db_data: {}
:wq

Run: docker-compose up -d and wait for process to finish and containers to start running

Run: docker-compose ps or docker ps


You can use the port to check the application status.

<nodegrid_IP>:8000