Introduction to Docker Compose

Introduction to docker compose

source: docker

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see the list of features.

Compose works in all environments: production, staging, development, testing, as well as CI workflows. You can learn more about each case in Common Use Cases.

Using Compose is basically a three-step process:

  • Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
  • Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
  • Run docker-compose up and Compose starts and runs your entire app. source : https://docs.docker.com/compose/

Install compose

sudo curl -L https://github.com/docker/compose/releases/download/1.20.1/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

Set permission executable

sudo chmod +x /usr/local/bin/docker-compose

Check docker-compose version

sudo docker-compose — version

Compose and Wordpress

create directory my_wordpress and enter the directory

mkdir /lab/my_wordpress
cd /lab/my_wordpress

create docker-compose.yml file

version: '3.2'

run compose

sudo docker-compose up -d

View container

sudo docker container ls

Access Wordpress from browser

Access wordpress on web browser

This is my little notes based my experiment and my learning. Keep learning and keep calm.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store